Add image to run

This commit is contained in:
Dolan
2018-08-09 01:55:50 +01:00
parent 94274733f4
commit e10c20fa42
9 changed files with 43 additions and 20 deletions

13
src/file/media/image.ts Normal file
View File

@ -0,0 +1,13 @@
import { ImageParagraph, PictureRun } from "../paragraph";
export class Image {
constructor(private readonly paragraph: ImageParagraph) {}
public get Paragraph(): ImageParagraph {
return this.paragraph;
}
public get Run(): PictureRun {
return this.paragraph.Run;
}
}

View File

@ -1,2 +1,3 @@
export * from "./media";
export * from "./data";
export * from "./image";

View File

@ -3,8 +3,9 @@ import * as sizeOf from "image-size";
import * as path from "path";
import { File } from "../file";
import { Image } from "../paragraph";
import { ImageParagraph } from "../paragraph";
import { IMediaData } from "./data";
import { Image } from "./image";
interface IHackedFile {
currentRelationshipId: number;
@ -20,7 +21,7 @@ export class Media {
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
`media/${mediaData.fileName}`,
);
return new Image(mediaData);
return new Image(new ImageParagraph(mediaData));
}
public static addImageFromBuffer(file: File, buffer: Buffer, width?: number, height?: number): Image {
@ -39,7 +40,7 @@ export class Media {
`media/${mediaData.fileName}`,
);
return new Image(mediaData);
return new Image(new ImageParagraph(mediaData));
}
private static generateId(): string {