Turn methods into "add()"
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
@ -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")
|
||||
|
Reference in New Issue
Block a user