force embed image to 100% scale

This commit is contained in:
Zsolt Viczian
2022-10-25 21:24:15 +02:00
parent d19b32d0c4
commit aa9118cdae
9 changed files with 61 additions and 22 deletions

View File

@@ -48,6 +48,7 @@ export declare type MimeType =
export type FileData = BinaryFileData & {
size: Size;
hasSVGwithBitmap: boolean;
shouldScale: boolean; //true if image should maintain its area, false if image should display at 100% its size
};
export type Size = {
@@ -182,6 +183,14 @@ export class EmbeddedFile {
}
return this.img; //images that are not SVGwithBitmap, only the light string is stored, since inverted and non-inverted are ===
}
/**
*
* @returns true if image should scale such as the updated images has the same area as the previous images, false if the image should be displayed at 100%
*/
public shouldScale() {
return !Boolean(this.linkParts && this.linkParts.original && this.linkParts.original.endsWith("|100%"));
}
}
export class EmbeddedFilesLoader {
@@ -367,6 +376,7 @@ export class EmbeddedFilesLoader {
created: data.created,
size: data.size,
hasSVGwithBitmap: data.hasSVGwithBitmap,
shouldScale: embeddedFile.shouldScale()
});
}
} else if (embeddedFile.isSVGwithBitmap) {
@@ -377,6 +387,7 @@ export class EmbeddedFilesLoader {
created: embeddedFile.mtime,
size: embeddedFile.size,
hasSVGwithBitmap: embeddedFile.isSVGwithBitmap,
shouldScale: embeddedFile.shouldScale()
});
}
}
@@ -395,6 +406,7 @@ export class EmbeddedFilesLoader {
created: data.created,
size: data.size,
hasSVGwithBitmap: false,
shouldScale: true
});
}
}