diff --git a/src/lib/components/chat/MessageInput/PromptCommands.svelte b/src/lib/components/chat/MessageInput/PromptCommands.svelte index 83e385612..04fb4c925 100644 --- a/src/lib/components/chat/MessageInput/PromptCommands.svelte +++ b/src/lib/components/chat/MessageInput/PromptCommands.svelte @@ -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'); diff --git a/src/routes/(app)/prompts/create/+page.svelte b/src/routes/(app)/prompts/create/+page.svelte index 083c9c358..9a85046ad 100644 --- a/src/routes/(app)/prompts/create/+page.svelte +++ b/src/routes/(app)/prompts/create/+page.svelte @@ -171,12 +171,18 @@
- Format your variables using square brackets like this: [variable] . Make sure to enclose them with '[' - and ']' . + and ']'. +
+ +
+ Utilize {`{{CLIPBOARD}}`} variable to have them replaced with clipboard content.