From affa6568d6b2cb3cbe22663c4c78a6ab1c9a19d9 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 1 Jan 2024 10:35:46 -0800 Subject: [PATCH 1/2] fix: code render issue --- src/app.css | 2 +- src/lib/components/chat/Messages/ResponseMessage.svelte | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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/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'; From 7d859141b4aacec7567ee5822b2dca5dece39877 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 1 Jan 2024 10:57:27 -0800 Subject: [PATCH 2/2] feat: arrowup edit message shortcut --- src/lib/components/chat/MessageInput.svelte | 18 ++++++++++++++++++ .../chat/Messages/UserMessage.svelte | 8 ++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) 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/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(); }}