feat: rich text input for chat

This commit is contained in:
Timothy J. Baek
2024-10-18 23:54:35 -07:00
parent 5e96922eba
commit f46b95300b
15 changed files with 268 additions and 178 deletions

View File

@@ -28,14 +28,14 @@
$: command = (prompt?.trim() ?? '').split(' ')?.at(-1) ?? '';
</script>
{#if ['/', '#', '@'].includes(command?.charAt(0))}
{#if ['/', '#', '@'].includes(command?.charAt(0)) || '\\#' === command.slice(0, 2)}
{#if command?.charAt(0) === '/'}
<Prompts bind:this={commandElement} bind:prompt bind:files {command} />
{:else if command?.charAt(0) === '#'}
{:else if command?.charAt(0) === '#' || '\\#' === command.slice(0, 2)}
<Knowledge
bind:this={commandElement}
bind:prompt
{command}
command={command.includes('\\#') ? command.slice(2) : command}
on:youtube={(e) => {
console.log(e);
dispatch('upload', {

View File

@@ -46,7 +46,7 @@
dispatch('select', item);
prompt = removeLastWordFromString(prompt, command);
const chatInputElement = document.getElementById('chat-textarea');
const chatInputElement = document.getElementById('chat-input');
await tick();
chatInputElement?.focus();
@@ -57,7 +57,7 @@
dispatch('url', url);
prompt = removeLastWordFromString(prompt, command);
const chatInputElement = document.getElementById('chat-textarea');
const chatInputElement = document.getElementById('chat-input');
await tick();
chatInputElement?.focus();
@@ -68,7 +68,7 @@
dispatch('youtube', url);
prompt = removeLastWordFromString(prompt, command);
const chatInputElement = document.getElementById('chat-textarea');
const chatInputElement = document.getElementById('chat-input');
await tick();
chatInputElement?.focus();

View File

@@ -58,7 +58,7 @@
onMount(async () => {
await tick();
const chatInputElement = document.getElementById('chat-textarea');
const chatInputElement = document.getElementById('chat-input');
await tick();
chatInputElement?.focus();
await tick();

View File

@@ -110,7 +110,7 @@
prompt = text;
const chatInputElement = document.getElementById('chat-textarea');
const chatInputElement = document.getElementById('chat-input');
await tick();

View File

@@ -213,7 +213,7 @@
transcription = `${transcription}${transcript}`;
await tick();
document.getElementById('chat-textarea')?.focus();
document.getElementById('chat-input')?.focus();
// Restart the inactivity timeout
timeoutId = setTimeout(() => {