mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-05 02:41:34 +00:00
fix: turn a large channel paste into a file when Paste Large Text as File is on (#31366)
This commit is contained in:
parent
bff0492b5f
commit
3d46a59b2d
1 changed files with 21 additions and 5 deletions
|
|
@ -24,7 +24,7 @@
|
|||
import { getSessionUser } from '$lib/apis/auths';
|
||||
|
||||
import { uploadFile } from '$lib/apis/files';
|
||||
import { WEBUI_API_BASE_URL } from '$lib/constants';
|
||||
import { WEBUI_API_BASE_URL, PASTED_TEXT_CHARACTER_LIMIT } from '$lib/constants';
|
||||
|
||||
import { getSuggestionRenderer } from '../common/RichTextInput/suggestions';
|
||||
import CommandSuggestionList from '../chat/MessageInput/CommandSuggestionList.svelte';
|
||||
|
|
@ -971,10 +971,26 @@
|
|||
|
||||
if (clipboardData && clipboardData.items) {
|
||||
for (const item of clipboardData.items) {
|
||||
const file = item.getAsFile();
|
||||
if (file) {
|
||||
await inputFilesHandler([file]);
|
||||
e.preventDefault();
|
||||
if (item.type === 'text/plain') {
|
||||
if ($settings?.largeTextAsFile ?? false) {
|
||||
const text = clipboardData.getData('text/plain');
|
||||
|
||||
if (text.length > PASTED_TEXT_CHARACTER_LIMIT) {
|
||||
e.preventDefault();
|
||||
const blob = new Blob([text], { type: 'text/plain' });
|
||||
const file = new File([blob], `Pasted_Text_${Date.now()}.txt`, {
|
||||
type: 'text/plain'
|
||||
});
|
||||
|
||||
await uploadFileHandler(file);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const file = item.getAsFile();
|
||||
if (file) {
|
||||
await inputFilesHandler([file]);
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue