merge with upstream master

This commit is contained in:
Sergio Mendonça
2018-08-14 11:27:08 -03:00
42 changed files with 486 additions and 102 deletions

View File

@ -20,4 +20,7 @@ export interface IMediaData {
}
// Needed because of: https://github.com/s-panferov/awesome-typescript-loader/issues/432
/**
* @ignore
*/
export const WORKAROUND2 = "";

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

@ -0,0 +1,17 @@
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;
}
public scale(factorX: number, factorY?: number): void {
this.paragraph.Run.scale(factorX, factorY);
}
}

View File

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

View File

@ -4,8 +4,9 @@ import * as path from "path";
import { File } from "../file";
import { IDrawingOptions } from "../drawing";
import { Image } from "../paragraph";
import { ImageParagraph } from "../paragraph";
import { IMediaData } from "./data";
import { Image } from "./image";
interface IHackedFile {
currentRelationshipId: number;
@ -21,7 +22,7 @@ export class Media {
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
`media/${mediaData.fileName}`,
);
return new Image(mediaData, drawingOptions);
return new Image(new ImageParagraph(mediaData, drawingOptions));
}
public static addImageFromBuffer(file: File, buffer: Buffer, width?: number, height?: number, drawingOptions?: IDrawingOptions): Image {
@ -40,7 +41,7 @@ export class Media {
`media/${mediaData.fileName}`,
);
return new Image(mediaData, drawingOptions);
return new Image(new ImageParagraph(mediaData, drawingOptions));
}
private static generateId(): string {
@ -106,12 +107,12 @@ export class Media {
fileName: key,
dimensions: {
pixels: {
x: dimensions.width,
y: dimensions.height,
x: Math.round(dimensions.width),
y: Math.round(dimensions.height),
},
emus: {
x: dimensions.width * 9525,
y: dimensions.height * 9525,
x: Math.round(dimensions.width * 9525),
y: Math.round(dimensions.height * 9525),
},
},
};