mirror of
https://github.com/open-webui/open-webui
synced 2024-11-16 05:24:02 +00:00
feat: CLIPBOARD variable for prompt preset
This commit is contained in:
parent
b993b66cfb
commit
7c7a80c450
@ -2,6 +2,7 @@
|
||||
import { prompts } from '$lib/stores';
|
||||
import { findWordIndices } from '$lib/utils';
|
||||
import { tick } from 'svelte';
|
||||
import toast from 'svelte-french-toast';
|
||||
|
||||
export let prompt = '';
|
||||
let selectedCommandIdx = 0;
|
||||
@ -24,7 +25,18 @@
|
||||
};
|
||||
|
||||
const confirmCommand = async (command) => {
|
||||
prompt = command.content;
|
||||
let text = command.content;
|
||||
|
||||
if (command.content.includes('{{CLIPBOARD}}')) {
|
||||
const clipboardText = await navigator.clipboard.readText().catch((err) => {
|
||||
toast.error('Failed to read clipboard contents');
|
||||
return '{{CLIPBOARD}}';
|
||||
});
|
||||
|
||||
text = command.content.replaceAll('{{CLIPBOARD}}', clipboardText);
|
||||
}
|
||||
|
||||
prompt = text;
|
||||
|
||||
const chatInputElement = document.getElementById('chat-textarea');
|
||||
|
||||
|
@ -171,12 +171,18 @@
|
||||
</div>
|
||||
|
||||
<div class="text-xs text-gray-400 dark:text-gray-500">
|
||||
Format your variables using square brackets like this: <span
|
||||
ⓘ Format your variables using square brackets like this: <span
|
||||
class=" text-gray-600 dark:text-gray-300 font-medium">[variable]</span
|
||||
>
|
||||
. Make sure to enclose them with
|
||||
<span class=" text-gray-600 dark:text-gray-300 font-medium">'['</span>
|
||||
and <span class=" text-gray-600 dark:text-gray-300 font-medium">']'</span> .
|
||||
and <span class=" text-gray-600 dark:text-gray-300 font-medium">']'</span>.
|
||||
</div>
|
||||
|
||||
<div class="text-xs text-gray-400 dark:text-gray-500">
|
||||
Utilize <span class=" text-gray-600 dark:text-gray-300 font-medium"
|
||||
>{`{{CLIPBOARD}}`}</span
|
||||
> variable to have them replaced with clipboard content.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user