From 83e8db9b6a8fb3728c083cc500fb94c7da62a965 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 10 Dec 2023 22:47:16 -0800 Subject: [PATCH] feat: /chat route support --- src/lib/components/chat/Messages.svelte | 430 ++++++++++++++---------- src/routes/(app)/+page.svelte | 124 +++---- src/routes/(app)/c/[id]/+page.svelte | 115 ++++--- 3 files changed, 373 insertions(+), 296 deletions(-) diff --git a/src/lib/components/chat/Messages.svelte b/src/lib/components/chat/Messages.svelte index 36fc6ce3..dc454550 100644 --- a/src/lib/components/chat/Messages.svelte +++ b/src/lib/components/chat/Messages.svelte @@ -163,6 +163,13 @@ // let editMessage = history.messages[messageId]; history.messages[messageId].edit = true; history.messages[messageId].editedContent = history.messages[messageId].content; + + await tick(); + + const editElement = document.getElementById(`message-edit-${messageId}`); + + editElement.style.height = ''; + editElement.style.height = `${editElement.scrollHeight}px`; }; const confirmEditMessage = async (messageId) => { @@ -195,6 +202,11 @@ await sendPrompt(userPrompt, userMessageId, $chatId); }; + const confirmEditResponseMessage = async (messageId) => { + history.messages[messageId].edit = false; + history.messages[messageId].content = history.messages[messageId].editedContent; + }; + const cancelEditMessage = (messageId) => { history.messages[messageId].edit = false; history.messages[messageId].editedContent = undefined; @@ -415,6 +427,7 @@ {#if message?.edit === true}