fix drag and drop on macOS
This commit is contained in:
parent
b182db81c9
commit
197fc68075
|
|
@ -13,7 +13,8 @@
|
||||||
{
|
{
|
||||||
"title": "Lightningbeam",
|
"title": "Lightningbeam",
|
||||||
"width": 1500,
|
"width": 1500,
|
||||||
"height": 1024
|
"height": 1024,
|
||||||
|
"dragDropEnabled": false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"security": {
|
"security": {
|
||||||
|
|
|
||||||
40
src/main.js
40
src/main.js
|
|
@ -3092,3 +3092,43 @@ const panes = {
|
||||||
func: infopanel
|
func: infopanel
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function convertToDataURL(filePath) {
|
||||||
|
try {
|
||||||
|
// Read the image file as a binary file (buffer)
|
||||||
|
const binaryData = await readBinaryFile(filePath);
|
||||||
|
const mimeType = getMimeType(filePath);
|
||||||
|
if (!mimeType) {
|
||||||
|
throw new Error('Unsupported image type');
|
||||||
|
}
|
||||||
|
|
||||||
|
const base64Data = binaryData.toString('base64');
|
||||||
|
const dataURL = `data:${mimeType};base64,${base64Data}`;
|
||||||
|
|
||||||
|
return dataURL;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error reading the image file:', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine the MIME type based on the file extension
|
||||||
|
function getMimeType(filePath) {
|
||||||
|
const ext = filePath.split('.').pop().toLowerCase();
|
||||||
|
switch (ext) {
|
||||||
|
case 'jpg':
|
||||||
|
case 'jpeg':
|
||||||
|
return 'image/jpeg';
|
||||||
|
case 'png':
|
||||||
|
return 'image/png';
|
||||||
|
case 'gif':
|
||||||
|
return 'image/gif';
|
||||||
|
case 'bmp':
|
||||||
|
return 'image/bmp';
|
||||||
|
case 'webp':
|
||||||
|
return 'image/webp';
|
||||||
|
default:
|
||||||
|
return null; // Unsupported file type
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue