Add image to run
This commit is contained in:
13
src/file/media/image.ts
Normal file
13
src/file/media/image.ts
Normal 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;
|
||||
}
|
||||
}
|
@ -1,2 +1,3 @@
|
||||
export * from "./media";
|
||||
export * from "./data";
|
||||
export * from "./image";
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user