|
@@ -364,7 +364,8 @@
|
|
|
multiple
|
|
|
on:change={async () => {
|
|
|
if (inputFiles && inputFiles.length > 0) {
|
|
|
- inputFilesHandler(inputFiles);
|
|
|
+ const _inputFiles = Array.from(inputFiles);
|
|
|
+ inputFilesHandler(_inputFiles);
|
|
|
} else {
|
|
|
toast.error($i18n.t(`File not found.`));
|
|
|
}
|
|
@@ -667,19 +668,26 @@
|
|
|
}}
|
|
|
on:paste={async (e) => {
|
|
|
const clipboardData = e.clipboardData || window.clipboardData;
|
|
|
- try {
|
|
|
- if (clipboardData && clipboardData.items) {
|
|
|
- const inputFiles = Array.from(clipboardData.items)
|
|
|
- .map((item) => item.getAsFile())
|
|
|
- .filter((file) => file);
|
|
|
|
|
|
- inputFilesHandler(inputFiles);
|
|
|
- } else {
|
|
|
- toast.error($i18n.t(`File not found.`));
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error('Error processing files:', error);
|
|
|
- toast.error($i18n.t(`An error occurred while processing files.`));
|
|
|
}
|
|
|
}}
|
|
|
/>
|