mirror of
https://github.com/open-webui/open-webui
synced 2025-06-25 17:57:20 +00:00
feat: allow image from prompt {{CLIPBOARD}}
This commit is contained in:
parent
3be1cb98d3
commit
1271d1dccc
@ -313,7 +313,7 @@
|
|||||||
|
|
||||||
<div class="w-full relative">
|
<div class="w-full relative">
|
||||||
{#if prompt.charAt(0) === '/'}
|
{#if prompt.charAt(0) === '/'}
|
||||||
<Prompts bind:this={promptsElement} bind:prompt />
|
<Prompts bind:this={promptsElement} bind:prompt bind:files />
|
||||||
{:else if prompt.charAt(0) === '#'}
|
{:else if prompt.charAt(0) === '#'}
|
||||||
<Documents
|
<Documents
|
||||||
bind:this={documentsElement}
|
bind:this={documentsElement}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
const i18n = getContext('i18n');
|
const i18n = getContext('i18n');
|
||||||
|
|
||||||
|
export let files;
|
||||||
export let prompt = '';
|
export let prompt = '';
|
||||||
let selectedCommandIdx = 0;
|
let selectedCommandIdx = 0;
|
||||||
let filteredPromptCommands = [];
|
let filteredPromptCommands = [];
|
||||||
@ -35,6 +36,32 @@
|
|||||||
return '{{CLIPBOARD}}';
|
return '{{CLIPBOARD}}';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(clipboardText);
|
||||||
|
|
||||||
|
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/')) {
|
||||||
|
const blob = await item.getType(type);
|
||||||
|
imageUrl = URL.createObjectURL(blob);
|
||||||
|
console.log(`Image URL (${type}): ${imageUrl}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (imageUrl) {
|
||||||
|
files = [
|
||||||
|
...files,
|
||||||
|
{
|
||||||
|
type: 'image',
|
||||||
|
url: imageUrl
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
text = command.content.replaceAll('{{CLIPBOARD}}', clipboardText);
|
text = command.content.replaceAll('{{CLIPBOARD}}', clipboardText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user