2.7.5
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled

This commit is contained in:
zsviczian
2025-01-05 23:09:16 +01:00
parent 63c56e0e98
commit 4f875a03a0
4 changed files with 45 additions and 14 deletions

View File

@@ -226,20 +226,25 @@ export const addFiles = async (
.forEach((f:FileData) => {
s.scene.elements
.filter((el:ExcalidrawElement)=>el.type === "image" && el.fileId === f.id && (
(el.crop && el.crop.naturalWidth !== f.size.width) || !el.customData?.pdfPageViewProps
(el.crop && el.crop?.naturalWidth !== f.size.width) || !el.customData?.pdfPageViewProps
))
.forEach((el:Mutable<ExcalidrawImageElement>) => {
s.dirty = true;
const scale = f.size.width / el.crop.naturalWidth;
el.crop = {
x: el.crop.x * scale,
y: el.crop.y * scale,
width: el.crop.width * scale,
height: el.crop.height * scale,
naturalWidth: f.size.width,
naturalHeight: f.size.height,
};
addAppendUpdateCustomData(el, { pdfPageViewProps: f.pdfPageViewProps});
if(el.crop) {
s.dirty = true;
const scale = f.size.width / el.crop.naturalWidth;
el.crop = {
x: el.crop.x * scale,
y: el.crop.y * scale,
width: el.crop.width * scale,
height: el.crop.height * scale,
naturalWidth: f.size.width,
naturalHeight: f.size.height,
};
}
if(!el.customData?.pdfPageViewProps) {
s.dirty = true;
addAppendUpdateCustomData(el, { pdfPageViewProps: f.pdfPageViewProps});
}
});
});