diff --git a/src/lib/components/chat/MessageInput/PromptCommands.svelte b/src/lib/components/chat/MessageInput/PromptCommands.svelte index 83e38561..04fb4c92 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 083c9c35..9a85046a 100644 --- a/src/routes/(app)/prompts/create/+page.svelte +++ b/src/routes/(app)/prompts/create/+page.svelte @@ -171,12 +171,18 @@