This commit is contained in:
Timothy Jaeryang Baek 2025-12-21 20:48:37 +04:00
parent fa924946b0
commit a1155dfeb7

View file

@ -112,25 +112,19 @@
const clipboardItems = await navigator.clipboard.read();
let imageUrl = null;
for (const item of clipboardItems) {
// Check for known image types
for (const type of item.types) {
if (type.startsWith('image/')) {
// get as file
const blob = await item.getType(type);
imageUrl = URL.createObjectURL(blob);
}
}
}
const file = new File([blob], `clipboard-image.${type.split('/')[1]}`, {
type: type
});
if (imageUrl) {
files = [
...files,
{
type: 'image',
url: imageUrl
inputFilesHandler([file]);
}
}
];
}
text = text.replaceAll('{{CLIPBOARD}}', clipboardText);
@ -931,22 +925,6 @@
if (clipboardData && clipboardData.items) {
for (const item of clipboardData.items) {
if (item.type.indexOf('image') !== -1) {
const blob = item.getAsFile();
const reader = new FileReader();
reader.onload = function (e) {
files = [
...files,
{
type: 'image',
url: `${e.target.result}`
}
];
};
reader.readAsDataURL(blob);
} else if (item?.kind === 'file') {
const file = item.getAsFile();
if (file) {
const _files = [file];
@ -955,7 +933,6 @@
}
}
}
}
}}
/>
{/key}