mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-16 20:07:49 +01:00
refac/enh: file upload with paste
This commit is contained in:
@@ -1279,6 +1279,13 @@
|
||||
};
|
||||
|
||||
reader.readAsDataURL(blob);
|
||||
} else if (item?.kind === 'file') {
|
||||
const file = item.getAsFile();
|
||||
if (file) {
|
||||
const _files = [file];
|
||||
await inputFilesHandler(_files);
|
||||
e.preventDefault();
|
||||
}
|
||||
} else if (item.type === 'text/plain') {
|
||||
if (($settings?.largeTextAsFile ?? false) && !shiftKey) {
|
||||
const text = clipboardData.getData('text/plain');
|
||||
@@ -1504,6 +1511,7 @@
|
||||
|
||||
if (clipboardData && clipboardData.items) {
|
||||
for (const item of clipboardData.items) {
|
||||
console.log(item);
|
||||
if (item.type.indexOf('image') !== -1) {
|
||||
const blob = item.getAsFile();
|
||||
const reader = new FileReader();
|
||||
@@ -1519,6 +1527,13 @@
|
||||
};
|
||||
|
||||
reader.readAsDataURL(blob);
|
||||
} else if (item?.kind === 'file') {
|
||||
const file = item.getAsFile();
|
||||
if (file) {
|
||||
const _files = [file];
|
||||
await inputFilesHandler(_files);
|
||||
e.preventDefault();
|
||||
}
|
||||
} else if (item.type === 'text/plain') {
|
||||
if (($settings?.largeTextAsFile ?? false) && !shiftKey) {
|
||||
const text = clipboardData.getData('text/plain');
|
||||
|
||||
Reference in New Issue
Block a user