This commit is contained in:
zsviczian
2023-11-20 23:05:55 +01:00
parent 4dc6c17486
commit 75d52c07b8

View File

@@ -105,41 +105,41 @@ const blobToBase64 = async (blob) => {
}
const getRequestObjFromSelectedElements = async (view) => {
await view.forceSave(true);
const viewElements = ea.getViewSelectedElements();
if(viewElements.length === 0) {
new Notice ("Aborting because there is nothing selected.",4000);
return;
}
const bb = ea.getBoundingBox(viewElements);
const size = (bb.width*bb.height);
const minRatio = Math.sqrt(360000/size);
const maxRatio = Math.sqrt(size/16000000);
const scale = minRatio > 1
? minRatio
: (
maxRatio > 1
? 1/maxRatio
: 1
);
const loader = ea.getEmbeddedFilesLoader(false);
const exportSettings = {
withBackground: true,
withTheme: true,
};
const img =
await ea.createPNG(
view.file.path,
scale,
exportSettings,
loader,
"light",
);
const dataURL = `data:image/png;base64,${await blobToBase64(img)}`;
return { json: async () => ({ image: dataURL }) }
await view.forceSave(true);
const viewElements = ea.getViewSelectedElements();
if(viewElements.length === 0) {
new Notice ("Aborting because there is nothing selected.",4000);
return;
}
const bb = ea.getBoundingBox(viewElements);
const size = (bb.width*bb.height);
const minRatio = Math.sqrt(360000/size);
const maxRatio = Math.sqrt(size/16000000);
const scale = minRatio > 1
? minRatio
: (
maxRatio > 1
? 1/maxRatio
: 1
);
const loader = ea.getEmbeddedFilesLoader(false);
const exportSettings = {
withBackground: true,
withTheme: true,
};
const img =
await ea.createPNG(
view.file.path,
scale,
exportSettings,
loader,
"light",
);
const dataURL = `data:image/png;base64,${await blobToBase64(img)}`;
return { json: async () => ({ image: dataURL }) }
}
const extractHTMLFromString = (result) => {
if(!result) return null;