Make media return a picture run instead

This commit is contained in:
Dolan
2019-06-23 22:36:01 +01:00
parent 427dc86915
commit dfe986331d
6 changed files with 31 additions and 15 deletions

View File

@ -55,12 +55,13 @@ export interface IParagraphOptions {
readonly level: number;
readonly custom?: boolean;
};
readonly children?: Array<TextRun | PictureRun | Hyperlink>;
}
export class Paragraph extends XmlComponent {
private readonly properties: ParagraphProperties;
constructor(options: string | IParagraphOptions) {
constructor(options: string | PictureRun | IParagraphOptions) {
super("w:p");
if (typeof options === "string") {
@ -70,6 +71,13 @@ export class Paragraph extends XmlComponent {
return;
}
if (options instanceof PictureRun) {
this.properties = new ParagraphProperties({});
this.root.push(this.properties);
this.root.push(options);
return;
}
this.properties = new ParagraphProperties({
border: options.border,
});
@ -163,6 +171,12 @@ export class Paragraph extends XmlComponent {
this.root.push(run);
}
}
if (options.children) {
for (const child of options.children) {
this.root.push(child);
}
}
}
public addRun(run: Run): Paragraph {