Turn methods into "add()"

This commit is contained in:
Dolan
2019-06-25 23:17:56 +01:00
parent 3ef8f5311d
commit e2574ec23b
55 changed files with 253 additions and 262 deletions

View File

@ -22,7 +22,7 @@
paragraph.addRun(institutionText);
paragraph.addRun(dateText);
doc.addParagraph(paragraph);
doc.add(paragraph);
const packer = new Packer();

View File

@ -17,7 +17,7 @@ const dateText = new TextRun({
paragraph.addRun(institutionText);
paragraph.addRun(dateText);
doc.addParagraph(paragraph);
doc.add(paragraph);
const packer = new Packer();

View File

@ -135,70 +135,70 @@ class DocumentCreator {
const skills = data[2] as object[];
const achivements = data[3] as object[];
const document = new Document();
document.addParagraph(
document.add(
new Paragraph({
text: "Dolan Miu",
heading: HeadingLevel.TITLE,
}),
);
document.addParagraph(this.createContactInfo(PHONE_NUMBER, PROFILE_URL, EMAIL));
document.addParagraph(this.createHeading("Education"));
document.add(this.createContactInfo(PHONE_NUMBER, PROFILE_URL, EMAIL));
document.add(this.createHeading("Education"));
for (const education of educations) {
document.addParagraph(
document.add(
this.createInstitutionHeader(education.schoolName, `${education.startDate.year} - ${education.endDate.year}`),
);
document.addParagraph(this.createRoleText(`${education.fieldOfStudy} - ${education.degree}`));
document.add(this.createRoleText(`${education.fieldOfStudy} - ${education.degree}`));
const bulletPoints = this.splitParagraphIntoBullets(education.notes);
bulletPoints.forEach((bulletPoint) => {
document.addParagraph(this.createBullet(bulletPoint));
document.add(this.createBullet(bulletPoint));
});
}
document.addParagraph(this.createHeading("Experience"));
document.add(this.createHeading("Experience"));
for (const position of experiences) {
document.addParagraph(
document.add(
this.createInstitutionHeader(
position.company.name,
this.createPositionDateText(position.startDate, position.endDate, position.isCurrent),
),
);
document.addParagraph(this.createRoleText(position.title));
document.add(this.createRoleText(position.title));
const bulletPoints = this.splitParagraphIntoBullets(position.summary);
bulletPoints.forEach((bulletPoint) => {
document.addParagraph(this.createBullet(bulletPoint));
document.add(this.createBullet(bulletPoint));
});
}
document.addParagraph(this.createHeading("Skills, Achievements and Interests"));
document.add(this.createHeading("Skills, Achievements and Interests"));
document.addParagraph(this.createSubHeading("Skills"));
document.addParagraph(this.createSkillList(skills));
document.add(this.createSubHeading("Skills"));
document.add(this.createSkillList(skills));
document.addParagraph(this.createSubHeading("Achievements"));
document.add(this.createSubHeading("Achievements"));
for (const achievementParagraph of this.createAchivementsList(achivements)) {
document.addParagraph(achievementParagraph);
document.add(achievementParagraph);
}
document.addParagraph(this.createSubHeading("Interests"));
document.add(this.createSubHeading("Interests"));
document.addParagraph(this.createInterests("Programming, Technology, Music Production, Web Design, 3D Modelling, Dancing."));
document.add(this.createInterests("Programming, Technology, Music Production, Web Design, 3D Modelling, Dancing."));
document.addParagraph(this.createHeading("References"));
document.add(this.createHeading("References"));
document.addParagraph(
document.add(
new Paragraph(
"Dr. Dean Mohamedally Director of Postgraduate Studies Department of Computer Science, University College London Malet Place, Bloomsbury, London WC1E d.mohamedally@ucl.ac.uk",
),
);
document.addParagraph(new Paragraph("More references upon request"));
document.addParagraph(
document.add(new Paragraph("More references upon request"));
document.add(
new Paragraph({
text: "This CV was generated in real-time based on my Linked-In profile from my personal website www.dolan.bio.",
alignment: AlignmentType.CENTER,

View File

@ -84,7 +84,7 @@ doc.Styles.createParagraphStyle("ListParagraph", "List Paragraph")
.basedOn("Normal");
doc.createImage(fs.readFileSync("./demo/images/pizza.gif"));
doc.addParagraph(
doc.add(
new Paragraph({
text: "HEADING",
heading: HeadingLevel.HEADING_1,
@ -92,7 +92,7 @@ doc.addParagraph(
}),
);
doc.Footer.addParagraph(
doc.Footer.add(
new Paragraph({
text: "1",
style: "normalPara",
@ -100,54 +100,54 @@ doc.Footer.addParagraph(
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "Ref. :",
style: "normalPara",
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "Date :",
style: "normalPara",
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "To,",
style: "normalPara",
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "The Superindenting Engineer,(O &M)",
style: "normalPara",
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "Sub : ",
style: "normalPara",
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "Ref. : ",
style: "normalPara",
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "Sir,",
style: "normalPara",
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "BRIEF DESCRIPTION",
style: "normalPara",
@ -161,9 +161,9 @@ const table = new Table({
table
.getRow(0)
.getCell(0)
.addParagraph(new Paragraph("Pole No."));
.add(new Paragraph("Pole No."));
doc.addTable(table);
doc.add(table);
const arrboth = [
{
@ -178,7 +178,7 @@ const arrboth = [
arrboth.forEach((item) => {
doc.createImage(fs.readFileSync(item.image));
doc.addParagraph(
doc.add(
new Paragraph({
text: item.comment,
style: "normalPara2",

View File

@ -6,7 +6,7 @@ import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
const paragraph = new Paragraph("Hello World");
doc.addParagraph(paragraph);
doc.add(paragraph);
const image = doc.createImage(fs.readFileSync("./demo/images/pizza.gif"));
const image2 = doc.createImage(fs.readFileSync("./demo/images/pizza.gif"));

View File

@ -9,7 +9,7 @@ const doc = new Document({
externalStyles: styles,
});
doc.addParagraph(new Paragraph({
doc.add(new Paragraph({
text: "Cool Heading Text",
heading: HeadingLevel.HEADING_1,
}));
@ -18,16 +18,16 @@ const paragraph = new Paragraph({
text: 'This is a custom named style from the template "MyFancyStyle"',
style: "MyFancyStyle",
});
doc.addParagraph(paragraph);
doc.add(paragraph);
doc.addParagraph(new Paragraph("Some normal text"));
doc.add(new Paragraph("Some normal text"));
doc.addParagraph(new Paragraph({
doc.add(new Paragraph({
text: "MyFancyStyle again",
style: "MyFancyStyle",
}));
doc.addParagraph(paragraph);
doc.add(paragraph);
const packer = new Packer();

View File

@ -5,12 +5,12 @@ import { AlignmentType, Document, Packer, Paragraph, TextRun } from "../build";
const doc = new Document();
doc.addParagraph(
doc.add(
new Paragraph({
text: "First Page",
}).pageBreak(),
);
doc.addParagraph(new Paragraph("Second Page"));
doc.add(new Paragraph("Second Page"));
const pageNumber = new TextRun("Page ").pageNumber();
@ -21,7 +21,7 @@ const pageoneheader = new Paragraph({
pageoneheader.addRun(pageNumber);
const firstPageHeader = doc.createFirstPageHeader();
firstPageHeader.addParagraph(pageoneheader);
firstPageHeader.add(pageoneheader);
const pagetwoheader = new Paragraph({
text: "My Title ",
@ -29,7 +29,7 @@ const pagetwoheader = new Paragraph({
});
pagetwoheader.addRun(pageNumber);
doc.Header.addParagraph(pagetwoheader);
doc.Header.add(pagetwoheader);
const packer = new Packer();

View File

@ -11,8 +11,8 @@ const paragraph2 = new Paragraph({
pageBreakBefore: true,
});
doc.addParagraph(paragraph);
doc.addParagraph(paragraph2);
doc.add(paragraph);
doc.add(paragraph2);
const packer = new Packer();

View File

@ -7,12 +7,12 @@ const doc = new Document();
const paragraph = new Paragraph("Hello World").pageBreak();
doc.addParagraph(paragraph);
doc.add(paragraph);
const header = doc.createHeader();
header.addParagraph(new Paragraph("Header on another page"));
header.add(new Paragraph("Header on another page"));
const footer = doc.createFooter();
footer.addParagraph(new Paragraph("Footer on another page"));
footer.add(new Paragraph("Footer on another page"));
doc.addSection({
headers: {
@ -25,7 +25,7 @@ doc.addSection({
pageNumberFormatType: PageNumberFormat.DECIMAL,
});
doc.addParagraph(new Paragraph("hello"));
doc.add(new Paragraph("hello"));
doc.addSection({
headers: {
@ -39,11 +39,11 @@ doc.addSection({
orientation: PageOrientation.LANDSCAPE,
});
doc.addParagraph(new Paragraph("hello in landscape"));
doc.add(new Paragraph("hello in landscape"));
const header2 = doc.createHeader();
const pageNumber = new TextRun("Page number: ").pageNumber();
header2.addParagraph(new Paragraph({}).addRun(pageNumber));
header2.add(new Paragraph({}).addRun(pageNumber));
doc.addSection({
headers: {
@ -52,7 +52,7 @@ doc.addSection({
orientation: PageOrientation.PORTRAIT,
});
doc.addParagraph(new Paragraph("Page number in the header must be 2, because it continues from the previous section."));
doc.add(new Paragraph("Page number in the header must be 2, because it continues from the previous section."));
doc.addSection({
headers: {
@ -62,7 +62,7 @@ doc.addSection({
orientation: PageOrientation.PORTRAIT,
});
doc.addParagraph(new Paragraph(
doc.add(new Paragraph(
"Page number in the header must be III, because it continues from the previous section, but is defined as upper roman.",
));
@ -75,7 +75,7 @@ doc.addSection({
orientation: PageOrientation.PORTRAIT,
});
doc.addParagraph(new Paragraph("Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section."));
doc.add(new Paragraph("Page number in the header must be 25, because it is defined to start at 25 and to be decimal in this section."));
const packer = new Packer();

View File

@ -8,8 +8,8 @@ const doc = new Document();
const paragraph = new Paragraph("Hello World").referenceFootnote(1);
const paragraph2 = new Paragraph("Hello World").referenceFootnote(2);
doc.addParagraph(paragraph);
doc.addParagraph(paragraph2);
doc.add(paragraph);
doc.add(paragraph2);
doc.createFootnote(new Paragraph("Test"));
doc.createFootnote(new Paragraph("My amazing reference"));

View File

@ -17,7 +17,7 @@ const dateText = new TextRun({
paragraph.addRun(institutionText);
paragraph.addRun(dateText);
doc.addParagraph(paragraph);
doc.add(paragraph);
const packer = new Packer();

View File

@ -46,14 +46,14 @@ doc.Styles.createParagraphStyle("ListParagraph", "List Paragraph")
const numberedAbstract = doc.Numbering.createAbstractNumbering();
numberedAbstract.createLevel(0, "lowerLetter", "%1)", "left");
doc.addParagraph(
doc.add(
new Paragraph({
text: "Test heading1, bold and italicized",
heading: HeadingLevel.HEADING_1,
}),
);
doc.addParagraph(new Paragraph("Some simple content"));
doc.addParagraph(
doc.add(new Paragraph("Some simple content"));
doc.add(
new Paragraph({
text: "Test heading2 with double red underline",
heading: HeadingLevel.HEADING_2,
@ -64,7 +64,7 @@ const letterNumbering = doc.Numbering.createConcreteNumbering(numberedAbstract);
const letterNumbering5 = doc.Numbering.createConcreteNumbering(numberedAbstract);
letterNumbering5.overrideLevel(0, 5);
doc.addParagraph(
doc.add(
new Paragraph({
text: "Option1",
numbering: {
@ -73,7 +73,7 @@ doc.addParagraph(
},
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "Option5 -- override 2 to 5",
numbering: {
@ -82,7 +82,7 @@ doc.addParagraph(
},
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "Option3",
numbering: {
@ -92,7 +92,7 @@ doc.addParagraph(
}),
);
doc.addParagraph(
doc.add(
new Paragraph({}).addRun(
new TextRun({
text: "Some monospaced content",
@ -103,20 +103,20 @@ doc.addParagraph(
),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "An aside, in light gray italics and indented",
style: "aside",
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "This is normal, but well-spaced text",
style: "wellSpaced",
}),
);
const para = new Paragraph({});
doc.addParagraph(para);
doc.add(para);
// Showing the different ways to create a TextRun
para.addRun(
new TextRun({

View File

@ -10,10 +10,10 @@ const table = new Table({
columns: 4,
});
doc.addTable(table);
doc.add(table);
table
.getCell(2, 2)
.addParagraph(new Paragraph("Hello"))
.add(new Paragraph("Hello"))
.Borders.addTopBorder(BorderStyle.DASH_DOT_STROKED, 3, "red")
.addBottomBorder(BorderStyle.DOUBLE, 3, "blue")
.addStartBorder(BorderStyle.DOT_DOT_DASH, 3, "green")

View File

@ -17,20 +17,20 @@ const anchorId = "anchorID";
// First create the bookmark
const bookmark = doc.createBookmark(anchorId, "Lorem Ipsum");
// That has header styling
doc.addParagraph(
doc.add(
new Paragraph({
heading: HeadingLevel.HEADING_1,
}).addBookmark(bookmark),
);
doc.addParagraph(new Paragraph("\n"));
doc.add(new Paragraph("\n"));
doc.addParagraph(new Paragraph(loremIpsum));
doc.addParagraph(new Paragraph({}).pageBreak());
doc.add(new Paragraph(loremIpsum));
doc.add(new Paragraph({}).pageBreak());
// Now the link back up to the bookmark
const hyperlink = doc.createInternalHyperLink(anchorId, `Click me!`);
doc.addParagraph(new Paragraph({}).addHyperLink(hyperlink));
doc.add(new Paragraph({}).addHyperLink(hyperlink));
const packer = new Packer();

View File

@ -13,7 +13,7 @@ const textRun1 = new TextRun({
rightToLeft: true,
});
paragraph1.addRun(textRun1);
doc.addParagraph(paragraph1);
doc.add(paragraph1);
const paragraph2 = new Paragraph({
bidirectional: true,
@ -24,7 +24,7 @@ const textRun2 = new TextRun({
rightToLeft: true,
});
paragraph2.addRun(textRun2);
doc.addParagraph(paragraph2);
doc.add(paragraph2);
const paragraph3 = new Paragraph({
bidirectional: true,
@ -35,7 +35,7 @@ const textRun3 = new TextRun({
rightToLeft: true,
});
paragraph3.addRun(textRun3);
doc.addParagraph(paragraph3);
doc.add(paragraph3);
const packer = new Packer();

View File

@ -6,7 +6,7 @@ import { Document, Media, Packer, Paragraph } from "../build";
const doc = new Document();
const paragraph = new Paragraph("Hello World");
doc.addParagraph(paragraph);
doc.add(paragraph);
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
const image2 = Media.addImage(doc, fs.readFileSync("./demo/images/dog.png"));
@ -20,12 +20,12 @@ const image6 = Media.addImage(doc, Buffer.from(imageBase64Data, "base64"), 100,
// I am adding an image to the paragraph rather than the document to make the image inline
paragraph.addImage(image5);
doc.addImage(image);
doc.addImage(image2);
doc.addImage(image3);
doc.addImage(image4);
doc.addImage(image5);
doc.addImage(image6);
doc.add(image);
doc.add(image2);
doc.add(image3);
doc.add(image4);
doc.add(image5);
doc.add(image6);
const packer = new Packer();

View File

@ -10,12 +10,12 @@ const table = new Table({
columns: 4,
});
doc.addTable(table);
doc.add(table);
table.getCell(2, 2).addParagraph(new Paragraph("Hello"));
table.getCell(2, 2).add(new Paragraph("Hello"));
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
table.getCell(1, 1).addParagraph(new Paragraph(image));
table.getCell(1, 1).add(new Paragraph(image));
const packer = new Packer();

View File

@ -7,7 +7,7 @@ const doc = new Document();
const paragraph = new Paragraph("No border!");
doc.addParagraph(paragraph);
doc.add(paragraph);
const borderParagraph = new Paragraph({
text: "I have borders on my top and bottom sides!",
@ -27,7 +27,7 @@ const borderParagraph = new Paragraph({
},
});
doc.addParagraph(borderParagraph);
doc.add(borderParagraph);
const packer = new Packer();

View File

@ -27,13 +27,13 @@ myStyles
.underline("double", "FF0000")
.spacing({ before: 240, after: 120 }); // TWIP for both
doc.addParagraph(
doc.add(
new Paragraph({
text: "Hello",
style: "myWonkyStyle",
}),
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "World",
heading: HeadingLevel.HEADING_2,

View File

@ -26,26 +26,26 @@ const toc = new TableOfContents("Summary", {
doc.addTableOfContents(toc);
doc.addParagraph(new Paragraph({
doc.add(new Paragraph({
text: "Header #1",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}));
doc.addParagraph(new Paragraph("I'm a little text very nicely written.'"));
doc.add(new Paragraph("I'm a little text very nicely written.'"));
doc.addParagraph(new Paragraph({
doc.add(new Paragraph({
text: "Header #2",
heading: HeadingLevel.HEADING_1,
pageBreakBefore: true,
}));
doc.addParagraph(new Paragraph("I'm a other text very nicely written.'"));
doc.addParagraph(new Paragraph({
doc.add(new Paragraph("I'm a other text very nicely written.'"));
doc.add(new Paragraph({
text: "Header #2.1",
heading: HeadingLevel.HEADING_2,
}));
doc.addParagraph(new Paragraph("I'm a another text very nicely written.'"));
doc.add(new Paragraph("I'm a another text very nicely written.'"));
doc.addParagraph(new Paragraph({
doc.add(new Paragraph({
text: "My Spectacular Style #1",
style: "MySpectacularStyle",
pageBreakBefore: true,

View File

@ -8,7 +8,7 @@ const doc = new Document();
const numbering = new Numbering();
const abstractNum = numbering.createAbstractNumbering();
abstractNum.createLevel(0, "upperRoman", "%1", "start").addParagraphProperty(new Indent({ left: 720, hanging: 260 }));
abstractNum.createLevel(0, "upperRoman", "%1", "start").addProperty(new Indent({ left: 720, hanging: 260 }));
const concrete = numbering.createConcreteNumbering(abstractNum);
@ -57,10 +57,10 @@ const item4 = new Paragraph({
},
});
doc.addParagraph(item1);
doc.addParagraph(item2);
doc.addParagraph(item3);
doc.addParagraph(item4);
doc.add(item1);
doc.add(item2);
doc.add(item3);
doc.add(item4);
const packer = new Packer();

View File

@ -8,9 +8,9 @@ const doc = new Document();
const numbering = new Numbering();
const abstractNum = numbering.createAbstractNumbering();
abstractNum.createLevel(0, "upperRoman", "%1", "start").addParagraphProperty(new Indent({ left: 720, hanging: 260 }));
abstractNum.createLevel(1, "decimal", "%2.", "start").addParagraphProperty(new Indent({ left: 1440, hanging: 980 }));
abstractNum.createLevel(2, "lowerLetter", "%3)", "start").addParagraphProperty(new Indent({ left: 14402160, hanging: 1700 }));
abstractNum.createLevel(0, "upperRoman", "%1", "start").addProperty(new Indent({ left: 720, hanging: 260 }));
abstractNum.createLevel(1, "decimal", "%2.", "start").addProperty(new Indent({ left: 1440, hanging: 980 }));
abstractNum.createLevel(2, "lowerLetter", "%3)", "start").addProperty(new Indent({ left: 14402160, hanging: 1700 }));
const concrete = numbering.createConcreteNumbering(abstractNum);
@ -43,10 +43,10 @@ const subSubP = new Paragraph({
},
});
doc.addParagraph(topLevelP);
doc.addParagraph(subP);
doc.addParagraph(secondSubP);
doc.addParagraph(subSubP);
doc.add(topLevelP);
doc.add(subP);
doc.add(secondSubP);
doc.add(subSubP);
const bullet1 = new Paragraph({
text: "Hey you",
@ -73,10 +73,10 @@ const bullet4 = new Paragraph({
},
});
doc.addParagraph(bullet1);
doc.addParagraph(bullet2);
doc.addParagraph(bullet3);
doc.addParagraph(bullet4);
doc.add(bullet1);
doc.add(bullet2);
doc.add(bullet3);
doc.add(bullet4);
const packer = new Packer();

View File

@ -21,7 +21,7 @@ fs.readFile(filePath, (err, data) => {
template: templateDocument,
});
const paragraph = new Paragraph("Hello World");
doc.addParagraph(paragraph);
doc.add(paragraph);
const packer = new Packer();
packer.toBuffer(doc).then((buffer) => {

View File

@ -10,14 +10,14 @@ const table = new Table({
columns: 2,
});
doc.addTable(table);
doc.add(table);
table
.getCell(1, 1)
.addParagraph(new Paragraph("This text should be in the middle of the cell"))
.add(new Paragraph("This text should be in the middle of the cell"))
.setVerticalAlign(VerticalAlign.CENTER);
table.getCell(1, 0).addParagraph(
table.getCell(1, 0).add(
new Paragraph({
text:
"Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah Blah",

View File

@ -10,12 +10,12 @@ let table = new Table({
columns: 2,
});
doc.addTable(table);
doc.add(table);
table.getCell(0, 0).addParagraph(new Paragraph("Hello"));
table.getCell(0, 0).add(new Paragraph("Hello"));
table.getRow(0).mergeCells(0, 1);
doc.addParagraph(
doc.add(
new Paragraph({
text: "Another table",
heading: HeadingLevel.HEADING_2,
@ -30,11 +30,11 @@ table = new Table({
columnWidths: [1000, 1000, 1000],
});
doc.addTable(table);
doc.add(table);
table
.getCell(0, 0)
.addParagraph(new Paragraph("World"))
.add(new Paragraph("World"))
.setMargins({
top: 1000,
bottom: 1000,
@ -43,7 +43,7 @@ table
});
table.getRow(0).mergeCells(0, 2);
doc.addParagraph(
doc.add(
new Paragraph({
text: "Another table",
heading: HeadingLevel.HEADING_2,
@ -63,14 +63,14 @@ table = new Table({
},
});
doc.addTable(table);
doc.add(table);
table.getCell(0, 0).addParagraph(new Paragraph("Foo"));
table.getCell(0, 1).addParagraph(new Paragraph("v"));
table.getCell(0, 0).add(new Paragraph("Foo"));
table.getCell(0, 1).add(new Paragraph("v"));
table
.getCell(1, 0)
.addParagraph(new Paragraph("Bar1"))
.add(new Paragraph("Bar1"))
.setShading({
fill: "b79c2f",
val: ShadingType.REVERSE_DIAGONAL_STRIPE,
@ -78,7 +78,7 @@ table
});
table
.getCell(1, 1)
.addParagraph(new Paragraph("Bar2"))
.add(new Paragraph("Bar2"))
.setShading({
fill: "42c5f4",
val: ShadingType.PERCENT_95,
@ -86,7 +86,7 @@ table
});
table
.getCell(1, 2)
.addParagraph(new Paragraph("Bar3"))
.add(new Paragraph("Bar3"))
.setShading({
fill: "880aa8",
val: ShadingType.PERCENT_10,
@ -94,7 +94,7 @@ table
});
table
.getCell(1, 3)
.addParagraph(new Paragraph("Bar4"))
.add(new Paragraph("Bar4"))
.setShading({
fill: "FF0000",
val: ShadingType.CLEAR,
@ -103,7 +103,7 @@ table
table.getRow(0).mergeCells(0, 3);
doc.addParagraph(new Paragraph("hi"));
doc.add(new Paragraph("hi"));
table = new Table({
rows: 2,
@ -112,7 +112,7 @@ table = new Table({
widthUnitType: WidthType.PERCENTAGE,
});
doc.addTable(table);
doc.add(table);
const packer = new Packer();

View File

@ -10,10 +10,10 @@ const paragraph2 = new Paragraph("Hello World 1->").addSequentialIdentifier("Lab
const paragraph3 = new Paragraph("Hello World 1->").addSequentialIdentifier("Another").addRun(new TextRun(" text after sequencial caption 3->")).addSequentialIdentifier("Label");
const paragraph4 = new Paragraph("Hello World 2->").addSequentialIdentifier("Another").addRun(new TextRun(" text after sequencial caption 4->")).addSequentialIdentifier("Label");
doc.addParagraph(paragraph);
doc.addParagraph(paragraph2);
doc.addParagraph(paragraph3);
doc.addParagraph(paragraph4);
doc.add(paragraph);
doc.add(paragraph2);
doc.add(paragraph3);
doc.add(paragraph4);
const packer = new Packer();

View File

@ -31,7 +31,7 @@ const table = new Table({
doc.add(table);
table.getCell(0, 0).addParagraph(new Paragraph("Hello"));
table.getCell(0, 0).add(new Paragraph("Hello"));
table.getRow(0).mergeCells(0, 1);
const packer = new Packer();

View File

@ -8,7 +8,7 @@ const paragraph = new Paragraph({});
const link = doc.createHyperlink("http://www.example.com", "Hyperlink");
paragraph.addHyperLink(link);
doc.addParagraph(paragraph);
doc.add(paragraph);
const packer = new Packer();

View File

@ -10,12 +10,12 @@ const table = new Table({
rows: 2,
columns: 2,
});
table.getCell(1, 1).addParagraph(new Paragraph(image));
table.getCell(1, 1).add(new Paragraph(image));
doc.addTable(table);
doc.add(table);
// doc.Header.createImage(fs.readFileSync("./demo/images/pizza.gif"));
doc.Header.addTable(table);
doc.Header.add(table);
// doc.Footer.createImage(fs.readFileSync("./demo/images/pizza.gif"));
const packer = new Packer();

View File

@ -5,7 +5,7 @@ import { Document, Media, Packer, Paragraph } from "../build";
const doc = new Document();
const image = Media.addImage(doc, fs.readFileSync("./demo/images/image1.jpeg"));
doc.addParagraph(new Paragraph("Hello World"));
doc.add(new Paragraph("Hello World"));
doc.Header.addImage(image);
doc.Header.createImage(fs.readFileSync("./demo/images/pizza.gif"));

View File

@ -6,15 +6,15 @@ import { Document, Packer, Paragraph, TextWrappingSide, TextWrappingType } from
const doc = new Document();
doc.addParagraph(new Paragraph(
doc.add(new Paragraph(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vehicula nec nulla vitae efficitur. Ut interdum mauris eu ipsum rhoncus, nec pharetra velit placerat. Sed vehicula libero ac urna molestie, id pharetra est pellentesque. Praesent iaculis vehicula fringilla. Duis pretium gravida orci eu vestibulum. Mauris tincidunt ipsum dolor, ut ornare dolor pellentesque id. Integer in nulla gravida, lacinia ante non, commodo ex. Vivamus vulputate nisl id lectus finibus vulputate. Ut et nisl mi. Cras fermentum augue arcu, ac accumsan elit euismod id. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed ac posuere nisi. Pellentesque tincidunt vehicula bibendum. Phasellus eleifend viverra nisl.",
));
doc.addParagraph(new Paragraph(
doc.add(new Paragraph(
"Proin ac purus faucibus, porttitor magna ut, cursus nisl. Vivamus ante purus, porta accumsan nibh eget, eleifend dignissim odio. Integer sed dictum est, aliquam lacinia justo. Donec ultrices auctor venenatis. Etiam interdum et elit nec elementum. Pellentesque nec viverra mauris. Etiam suscipit leo nec velit fringilla mattis. Pellentesque justo lacus, sodales eu condimentum in, dapibus finibus lacus. Morbi vitae nibh sit amet sem molestie feugiat. In non porttitor enim.",
));
doc.addParagraph(new Paragraph(
doc.add(new Paragraph(
"Ut eget diam cursus quam accumsan interdum at id ante. Ut mollis mollis arcu, eu scelerisque dui tempus in. Quisque aliquam, augue quis ornare aliquam, ex purus ultrices mauris, ut porta dolor dolor nec justo. Nunc a tempus odio, eu viverra arcu. Suspendisse vitae nibh nec mi pharetra tempus. Mauris ut ullamcorper sapien, et sagittis sapien. Vestibulum in urna metus. In scelerisque, massa id bibendum tempus, quam orci rutrum turpis, a feugiat nisi ligula id metus. Praesent id dictum purus. Proin interdum ipsum nulla.",
));

View File

@ -11,11 +11,11 @@ const doc = new Document(
},
);
doc.Header.addParagraph(
doc.Header.add(
new Paragraph("Foo Bar corp. ").addRun(new TextRun("Page Number ").pageNumber()).addRun(new TextRun(" to ").numberOfTotalPages()),
);
doc.Footer.addParagraph(
doc.Footer.add(
new Paragraph({
text: "Foo Bar corp. ",
alignment: AlignmentType.CENTER,
@ -24,11 +24,11 @@ doc.Footer.addParagraph(
.addRun(new TextRun(" to ").numberOfTotalPages()),
);
doc.addParagraph(new Paragraph("Hello World 1").pageBreak());
doc.addParagraph(new Paragraph("Hello World 2").pageBreak());
doc.addParagraph(new Paragraph("Hello World 3").pageBreak());
doc.addParagraph(new Paragraph("Hello World 4").pageBreak());
doc.addParagraph(new Paragraph("Hello World 5").pageBreak());
doc.add(new Paragraph("Hello World 1").pageBreak());
doc.add(new Paragraph("Hello World 2").pageBreak());
doc.add(new Paragraph("Hello World 3").pageBreak());
doc.add(new Paragraph("Hello World 4").pageBreak());
doc.add(new Paragraph("Hello World 5").pageBreak());
const packer = new Packer();

View File

@ -10,9 +10,9 @@ const table = new Table({
columns: 4,
});
doc.addTable(table);
doc.add(table);
table.getCell(2, 2).addParagraph(new Paragraph("Hello"));
table.getCell(2, 2).add(new Paragraph("Hello"));
const packer = new Packer();

View File

@ -11,18 +11,18 @@ const doc = new Document(
},
);
doc.addParagraph(
doc.add(
new Paragraph({
text: "Hello",
heading: HeadingLevel.HEADING_1,
}),
);
doc.addParagraph(
doc.add(
new Paragraph(
"Himenaeos duis luctus nullam fermentum lobortis potenti vivamus non dis, sed facilisis ultricies scelerisque aenean risus hac senectus. Adipiscing id venenatis justo ante gravida placerat, ac curabitur dis pellentesque proin bibendum risus, aliquam porta taciti vulputate primis. Tortor ipsum fermentum quam vel convallis primis nisl praesent tincidunt, lobortis quisque felis vitae condimentum class ut sem nam, aenean potenti pretium ac amet lacinia himenaeos mi. Aliquam nisl turpis hendrerit est morbi malesuada, augue interdum mus inceptos curabitur tristique, parturient feugiat sodales nulla facilisi. Aliquam non pulvinar purus nulla ex integer, velit faucibus vitae at bibendum quam, risus elit aenean adipiscing posuere.",
),
);
doc.addParagraph(
doc.add(
new Paragraph(
"Sed laoreet id mattis egestas nam mollis elit lacinia convallis dui tincidunt ultricies habitant, pharetra per maximus interdum neque tempor risus efficitur morbi imperdiet senectus. Lectus laoreet senectus finibus inceptos donec potenti fermentum, ultrices eleifend odio suscipit magnis tellus maximus nibh, ac sit nullam eget felis himenaeos. Diam class sem magnis aenean commodo faucibus id proin mi, nullam sodales nec mus parturient ornare ad inceptos velit hendrerit, bibendum placerat eleifend integer facilisis urna dictumst suspendisse.",
),

View File

@ -10,41 +10,41 @@ const table = new Table({
columns: 6,
});
doc.addTable(table);
doc.add(table);
let row = 0;
table.getCell(row, 0).addParagraph(new Paragraph("0,0"));
table.getCell(row, 1).addParagraph(new Paragraph("0,1"));
table.getCell(row, 3).addParagraph(new Paragraph("0,3"));
table.getCell(row, 4).addParagraph(new Paragraph("0,4"));
table.getCell(row, 0).add(new Paragraph("0,0"));
table.getCell(row, 1).add(new Paragraph("0,1"));
table.getCell(row, 3).add(new Paragraph("0,3"));
table.getCell(row, 4).add(new Paragraph("0,4"));
table.getRow(row).mergeCells(4, 5);
table.getRow(row).mergeCells(1, 2);
row = 1;
table.getCell(row, 0).addParagraph(new Paragraph("1,0"));
table.getCell(row, 2).addParagraph(new Paragraph("1,2"));
table.getCell(row, 4).addParagraph(new Paragraph("1,4"));
table.getCell(row, 0).add(new Paragraph("1,0"));
table.getCell(row, 2).add(new Paragraph("1,2"));
table.getCell(row, 4).add(new Paragraph("1,4"));
table.getRow(row).mergeCells(4, 5);
table.getRow(row).mergeCells(2, 3);
table.getRow(row).mergeCells(0, 1);
row = 2;
table.getCell(row, 0).addParagraph(new Paragraph("2,0"));
table.getCell(row, 1).addParagraph(new Paragraph("2,1"));
table.getCell(row, 2).addParagraph(new Paragraph("2,2"));
table.getCell(row, 3).addParagraph(new Paragraph("2,3"));
table.getCell(row, 4).addParagraph(new Paragraph("2,4"));
table.getCell(row, 0).add(new Paragraph("2,0"));
table.getCell(row, 1).add(new Paragraph("2,1"));
table.getCell(row, 2).add(new Paragraph("2,2"));
table.getCell(row, 3).add(new Paragraph("2,3"));
table.getCell(row, 4).add(new Paragraph("2,4"));
table.getRow(row).mergeCells(4, 5);
table.getRow(row).mergeCells(1, 2);
row = 3;
table.getCell(row, 0).addParagraph(new Paragraph("3,0"));
table.getCell(row, 1).addParagraph(new Paragraph("3,1"));
table.getCell(row, 2).addParagraph(new Paragraph("3,2"));
table.getCell(row, 3).addParagraph(new Paragraph("3,3"));
table.getCell(row, 4).addParagraph(new Paragraph("3,4"));
table.getCell(row, 5).addParagraph(new Paragraph("3,5"));
table.getCell(row, 0).add(new Paragraph("3,0"));
table.getCell(row, 1).add(new Paragraph("3,1"));
table.getCell(row, 2).add(new Paragraph("3,2"));
table.getCell(row, 3).add(new Paragraph("3,3"));
table.getCell(row, 4).add(new Paragraph("3,4"));
table.getCell(row, 5).add(new Paragraph("3,5"));
row = 4;
table.getCell(row, 0).addParagraph(new Paragraph("4,0"));
table.getCell(row, 5).addParagraph(new Paragraph("4,5"));
table.getCell(row, 0).add(new Paragraph("4,0"));
table.getCell(row, 5).add(new Paragraph("4,5"));
table.getRow(row).mergeCells(0, 4);
const packer = new Packer();

View File

@ -10,11 +10,11 @@ const table = new Table({
columns: 4,
});
doc.addTable(table);
doc.add(table);
table.getCell(2, 2).addParagraph(new Paragraph("Hello"));
table.getCell(2, 2).add(new Paragraph("Hello"));
table.getColumn(3).mergeCells(1, 2);
// table.getCell(3, 2).addParagraph(new Paragraph("Hello"));
// table.getCell(3, 2).add(new Paragraph("Hello"));
const packer = new Packer();

View File

@ -7,7 +7,7 @@ import { Document, HorizontalPositionAlign, HorizontalPositionRelativeFrom, Pack
const doc = new Document();
const paragraph = new Paragraph("Hello World");
doc.addParagraph(paragraph);
doc.add(paragraph);
doc.createImage(fs.readFileSync("./demo/images/image1.jpeg"));
doc.createImage(fs.readFileSync("./demo/images/dog.png").toString("base64"));

View File

@ -22,14 +22,14 @@ const dateText = new TextRun({
paragraph.addRun(institutionText);
paragraph.addRun(dateText);
doc.addParagraph(paragraph);
doc.add(paragraph);
doc.addParagraph(new Paragraph({
doc.add(new Paragraph({
text: "Hello World",
heading: HeadingLevel.HEADING_1,
}));
doc.addParagraph(new Paragraph("Foo bar"));
doc.addParagraph(new Paragraph("Github is the best"));
doc.add(new Paragraph("Foo bar"));
doc.add(new Paragraph("Github is the best"));
const packer = new Packer();

View File

@ -9,7 +9,7 @@ const doc = new Document(undefined, {
const paragraph = new Paragraph("Hello World");
doc.addParagraph(paragraph);
doc.add(paragraph);
const packer = new Packer();

View File

@ -5,10 +5,10 @@ import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
doc.addParagraph(new Paragraph("Hello World"));
doc.add(new Paragraph("Hello World"));
doc.Header.addParagraph(new Paragraph("Header text"));
doc.Footer.addParagraph(new Paragraph("Footer text"));
doc.Header.add(new Paragraph("Header text"));
doc.Footer.add(new Paragraph("Footer text"));
const packer = new Packer();

View File

@ -5,7 +5,7 @@ import { Document, Packer, Paragraph } from "../build";
const doc = new Document();
doc.addParagraph(new Paragraph("Hello World"));
doc.add(new Paragraph("Hello World"));
doc.Header.createImage(fs.readFileSync("./demo/images/pizza.gif"));
doc.Footer.createImage(fs.readFileSync("./demo/images/pizza.gif"));

View File

@ -39,7 +39,7 @@ var doc = new docx.Document();
var paragraph = new docx.Paragraph("Some cool text here.");
// Add more text into the paragraph if you wish
paragraph.addRun(new docx.TextRun("Lorem Ipsum Foo Bar"));
doc.addParagraph(paragraph);
doc.add(paragraph);
// Used to export the file into a .docx file
var packer = new docx.Packer();

View File

@ -92,7 +92,7 @@ This is just a guideline, and the rules can sometimes be broken.
*Note:* This may look like its breaking the previous guideline, but it has semantically different meanings. The previous one is using data to construct an object, whereas this one is simply adding elements into the document:
```js
public addParagraph(paragraph: Paragraph) {
public add(paragraph: Paragraph) {
this.root.push(paragraph);
}
```

View File

@ -11,8 +11,8 @@ var paragraph = new docx.Paragraph(text).bullet();
var text2 = new docx.TextRun("Are awesome");
var paragraph2 = new docx.Paragraph(text2).bullet();
doc.addParagraph(paragraph);
doc.addParagraph(paragraph2);
doc.add(paragraph);
doc.add(paragraph2);
```
### This will produce:

View File

@ -23,7 +23,7 @@ var paragraph = new docx.Paragraph("Short hand notation for adding text.");
After you create the paragraph, you must add the paragraph into the `document`:
```js
doc.addParagraph(paragraph);
doc.add(paragraph);
```
## Styles

View File

@ -39,7 +39,7 @@ doc.createParagraph("Cool Heading Text").heading1();
let paragraph = new docx.Paragraph('This is a custom named style from the template "Cool New Style"');
paragraph.style("Cool New Style");
doc.addParagraph(paragraph);
doc.add(paragraph);
doc.createParagraph("Some normal text");
```

View File

@ -58,15 +58,15 @@ const toc = new TableOfContents("Summary", {
doc.addTableOfContents(toc);
doc.addParagraph(new Paragraph("Header #1").heading1().pageBreakBefore());
doc.addParagraph(new Paragraph("I'm a little text, very nicely written.'"));
doc.add(new Paragraph("Header #1").heading1().pageBreakBefore());
doc.add(new Paragraph("I'm a little text, very nicely written.'"));
doc.addParagraph(new Paragraph("Header #2").heading1().pageBreakBefore());
doc.addParagraph(new Paragraph("I'm another text very nicely written.'"));
doc.addParagraph(new Paragraph("Header #2.1").heading2());
doc.addParagraph(new Paragraph("I'm another text very nicely written.'"));
doc.add(new Paragraph("Header #2").heading1().pageBreakBefore());
doc.add(new Paragraph("I'm another text very nicely written.'"));
doc.add(new Paragraph("Header #2.1").heading2());
doc.add(new Paragraph("I'm another text very nicely written.'"));
doc.addParagraph(new Paragraph("My Spectacular Style #1").style("MySpectacularStyle").pageBreakBefore());
doc.add(new Paragraph("My Spectacular Style #1").style("MySpectacularStyle").pageBreakBefore());
```
### Complete example

View File

@ -4,10 +4,10 @@ You can create tables with `docx`. More information can be found [here](http://o
## Create Table
To create a table, simply create one with `new Table()`, then add it to the document: `doc.addTable()`.
To create a table, simply create one with `new Table()`, then add it to the document: `doc.add()`.
```ts
const table = doc.addTable(new Table({
const table = doc.add(new Table({
rows: [NUMBER OF ROWS],
columns: [NUMBER OF COLUMNS]
});
@ -17,7 +17,7 @@ Alternatively, you can create a table object directly, and then add it in the `d
```ts
const table = new Table(4, 4);
doc.addTable(table);
doc.add(table);
```
The snippet below creates a table of 2 rows and 4 columns.
@ -27,7 +27,7 @@ const table = new Table({
rows: 2,
columns: 4,
});
doc.addTable(table);
doc.add(table);
```
## Rows and Columns
@ -92,10 +92,10 @@ const cell = column.getCell(2);
### Add paragraph to a cell
Once you have got the cell, you can add data to it with the `addParagraph()` method.
Once you have got the cell, you can add data to it with the `add()` method.
```ts
cell.addParagraph(new Paragraph("Hello"));
cell.add(new Paragraph("Hello"));
```
### Set width of a cell
@ -226,7 +226,7 @@ It has not been implemented yet, but it will follow a similar structure as mergi
To have a table within a table
```ts
cell.addTable(new Table(1, 1));
cell.add(new Table(1, 1));
```
## Pagination

View File

@ -37,7 +37,7 @@ export class Document extends XmlComponent {
this.root.push(this.body);
}
public addParagraph(paragraph: Paragraph): Document {
public add(paragraph: Paragraph | Table): Document {
this.body.push(paragraph);
return this;
}
@ -47,11 +47,6 @@ export class Document extends XmlComponent {
return this;
}
public addTable(table: Table): Document {
this.body.push(table);
return this;
}
public get Body(): Body {
return this.body;
}

View File

@ -80,20 +80,18 @@ describe("File", () => {
});
});
describe("#addParagraph", () => {
it("should call the underlying document's addParagraph", () => {
describe("#add", () => {
it("should call the underlying document's add a Paragraph", () => {
const file = new File();
const spy = sinon.spy(file.Document, "addParagraph");
const spy = sinon.spy(file.Document, "add");
file.add(new Paragraph({}));
expect(spy.called).to.equal(true);
});
});
describe("#add", () => {
it("should call the underlying document's addTable", () => {
it("should call the underlying document's add when adding a Table", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Document, "addTable");
const spy = sinon.spy(wrapper.Document, "add");
wrapper.add(
new Table({
rows: 1,
@ -104,6 +102,17 @@ describe("File", () => {
expect(spy.called).to.equal(true);
});
it("should call the underlying document's add when adding an Image (paragraph)", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Document, "add");
// tslint:disable-next-line:no-any
wrapper.add(new Paragraph(""));
expect(spy.called).to.equal(true);
});
});
describe("#add", () => {
it("should call the underlying document's addTableOfContents", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Document, "addTableOfContents");
@ -111,22 +120,13 @@ describe("File", () => {
expect(spy.called).to.equal(true);
});
it("should call the underlying document's addImage", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Document, "addParagraph");
// tslint:disable-next-line:no-any
wrapper.add(new Paragraph(""));
expect(spy.called).to.equal(true);
});
});
describe("#createImage", () => {
it("should call the underlying document's createImage", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Media, "addMedia");
const wrapperSpy = sinon.spy(wrapper.Document, "addParagraph");
const wrapperSpy = sinon.spy(wrapper.Document, "add");
wrapper.createImage("");
expect(spy.called).to.equal(true);

View File

@ -114,11 +114,11 @@ export class File {
public add(item: Paragraph | Table | TableOfContents): File {
if (item instanceof Paragraph) {
this.document.addParagraph(item);
this.document.add(item);
}
if (item instanceof Table) {
this.document.addTable(item);
this.document.add(item);
}
if (item instanceof TableOfContents) {
@ -136,7 +136,7 @@ export class File {
): Paragraph {
const image = Media.addImage(this, buffer, width, height, drawingOptions);
const paragraph = new Paragraph(image);
this.document.addParagraph(paragraph);
this.document.add(paragraph);
return paragraph;
}

View File

@ -20,7 +20,7 @@ export class Footnote extends XmlComponent {
);
}
public addParagraph(paragraph: Paragraph): void {
public add(paragraph: Paragraph): void {
paragraph.addRunToFront(new FootnoteRefRun());
this.root.push(paragraph);
}

View File

@ -37,7 +37,7 @@ export class FootNotes extends XmlComponent {
);
const begin = new Footnote(-1, FootnoteType.SEPERATOR);
begin.addParagraph(
begin.add(
new Paragraph({
spacing: {
after: 0,
@ -49,7 +49,7 @@ export class FootNotes extends XmlComponent {
this.root.push(begin);
const spacing = new Footnote(0, FootnoteType.CONTINUATION_SEPERATOR);
spacing.addParagraph(
spacing.add(
new Paragraph({
spacing: {
after: 0,
@ -63,7 +63,7 @@ export class FootNotes extends XmlComponent {
public createFootNote(paragraph: Paragraph): void {
const footnote = new Footnote(this.currentId);
footnote.addParagraph(paragraph);
footnote.add(paragraph);
this.root.push(footnote);
this.currentId++;

View File

@ -22,13 +22,9 @@ export class TableCell extends XmlComponent {
this.root.push(this.properties);
}
public addParagraph(content: Paragraph): TableCell {
this.root.push(content);
return this;
}
public add(item: Paragraph | Table): TableCell {
this.root.push(item);
public addTable(content: Table): TableCell {
this.root.push(content);
return this;
}
@ -36,7 +32,7 @@ export class TableCell extends XmlComponent {
// Cells must end with a paragraph
if (!(this.root[this.root.length - 1] instanceof Paragraph)) {
const para = new Paragraph({});
this.addParagraph(para);
this.add(para);
}
return super.prepForXml();
}

View File

@ -163,19 +163,19 @@ describe("Table", () => {
table
.getRow(0)
.getCell(0)
.addParagraph(new Paragraph("A1"));
.add(new Paragraph("A1"));
table
.getRow(0)
.getCell(1)
.addParagraph(new Paragraph("B1"));
.add(new Paragraph("B1"));
table
.getRow(1)
.getCell(0)
.addParagraph(new Paragraph("A2"));
.add(new Paragraph("A2"));
table
.getRow(1)
.getCell(1)
.addParagraph(new Paragraph("B2"));
.add(new Paragraph("B2"));
const tree = new Formatter().format(table);
const cell = (c) => ({
"w:tc": [
@ -221,10 +221,10 @@ describe("Table", () => {
rows: 2,
columns: 2,
});
table.getCell(0, 0).addParagraph(new Paragraph("A1"));
table.getCell(0, 1).addParagraph(new Paragraph("B1"));
table.getCell(1, 0).addParagraph(new Paragraph("A2"));
table.getCell(1, 1).addParagraph(new Paragraph("B2"));
table.getCell(0, 0).add(new Paragraph("A1"));
table.getCell(0, 1).add(new Paragraph("B1"));
table.getCell(1, 0).add(new Paragraph("A2"));
table.getCell(1, 1).add(new Paragraph("B2"));
const tree = new Formatter().format(table);
const cell = (c) => ({
"w:tc": [
@ -295,7 +295,7 @@ describe("Table", () => {
rows: 1,
columns: 1,
});
parentTable.getCell(0, 0).addTable(
parentTable.getCell(0, 0).add(
new Table({
rows: 1,
columns: 1,
@ -322,7 +322,7 @@ describe("Table", () => {
rows: 1,
columns: 1,
});
parentTable.getCell(0, 0).addParagraph(new Paragraph("Hello"));
parentTable.getCell(0, 0).add(new Paragraph("Hello"));
const tree = new Formatter().format(parentTable);
expect(tree)
.to.have.property("w:tbl")