diff --git a/src/app.css b/src/app.css index 34621fde..9665d026 100644 --- a/src/app.css +++ b/src/app.css @@ -16,7 +16,7 @@ html { code { /* white-space-collapse: preserve !important; */ - white-space: pre; + overflow-x: auto; width: auto; } diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index bb941c90..d2fe8ca2 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -298,6 +298,24 @@ submitPrompt(prompt); } }} + on:keydown={(e) => { + if (prompt === '' && e.key == 'ArrowUp') { + e.preventDefault(); + + const userMessageElement = [ + ...document.getElementsByClassName('user-message') + ]?.at(-1); + + const editButton = [ + ...document.getElementsByClassName('edit-user-message-button') + ]?.at(-1); + + console.log(userMessageElement); + + userMessageElement.scrollIntoView({ block: 'center' }); + editButton?.click(); + } + }} rows="1" on:input={(e) => { e.target.style.height = ''; diff --git a/src/lib/components/chat/Messages/ResponseMessage.svelte b/src/lib/components/chat/Messages/ResponseMessage.svelte index bb81b2c9..6f821b46 100644 --- a/src/lib/components/chat/Messages/ResponseMessage.svelte +++ b/src/lib/components/chat/Messages/ResponseMessage.svelte @@ -88,6 +88,7 @@ let code = block.querySelector('code'); code.style.borderTopRightRadius = 0; code.style.borderTopLeftRadius = 0; + code.style.whiteSpace = 'pre'; let topBarDiv = document.createElement('div'); topBarDiv.style.backgroundColor = '#202123'; diff --git a/src/lib/components/chat/Messages/UserMessage.svelte b/src/lib/components/chat/Messages/UserMessage.svelte index a760ce3a..693d20e2 100644 --- a/src/lib/components/chat/Messages/UserMessage.svelte +++ b/src/lib/components/chat/Messages/UserMessage.svelte @@ -24,6 +24,8 @@ editElement.style.height = ''; editElement.style.height = `${editElement.scrollHeight}px`; + + editElement?.focus(); }; const editMessageConfirmHandler = async () => { @@ -43,7 +45,9 @@
- You +
+ You +
{ editMessageHandler(); }}