Simplify multiple addXXX methods into a single add method

This commit is contained in:
Dolan
2019-06-25 01:52:02 +01:00
parent c97d15cb9f
commit 384d144a85
6 changed files with 36 additions and 52 deletions

View File

@ -22,16 +22,14 @@ export class HeaderWrapper {
this.relationships = new Relationships();
}
public addParagraph(paragraph: Paragraph): void {
this.header.addParagraph(paragraph);
}
public add(item: Paragraph | Table): HeaderWrapper {
this.header.addChildElement(item);
public addTable(table: Table): void {
this.header.addTable(table);
return this;
}
public addImage(image: Image): HeaderWrapper {
this.header.addParagraph(image.Paragraph);
this.header.add(image.Paragraph);
return this;
}
@ -47,7 +45,7 @@ export class HeaderWrapper {
): Paragraph {
const image = Media.addImage(this, buffer, width, height, drawingOptions);
const paragraph = new Paragraph(image);
this.addParagraph(paragraph);
this.add(paragraph);
return paragraph;
}