named this addRun because I realised Text can be a Run, but also a Picture can be a run
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { Num } from "../../numbering/num";
|
||||
import { Run } from "../run";
|
||||
import { TextRun } from "../run/text-run";
|
||||
import { XmlComponent } from "../xml-components";
|
||||
|
||||
@ -24,14 +25,14 @@ export class Paragraph extends XmlComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public addText(run: TextRun): Paragraph {
|
||||
public addRun(run: Run): Paragraph {
|
||||
this.root.push(run);
|
||||
return this;
|
||||
}
|
||||
|
||||
public createTextRun(text: string): TextRun {
|
||||
const run = new TextRun(text);
|
||||
this.addText(run);
|
||||
this.addRun(run);
|
||||
return run;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ describe("Formatter", () => {
|
||||
|
||||
it("should format simple paragraph with bold text", () => {
|
||||
const paragraph = new docx.Paragraph();
|
||||
paragraph.addText(new docx.TextRun("test").bold());
|
||||
paragraph.addRun(new docx.TextRun("test").bold());
|
||||
const newJson = formatter.format(paragraph);
|
||||
assert.isDefined(newJson["w:p"][1]["w:r"][0]["w:rPr"][0]["w:b"][0]._attr["w:val"]);
|
||||
});
|
||||
|
Reference in New Issue
Block a user