multiple lines chat message input

This commit is contained in:
gozineb 2023-06-06 13:08:26 +02:00
parent a743821dc0
commit 65fd3637da
2 changed files with 8 additions and 2 deletions

View File

@ -30,6 +30,7 @@ const ChatMessage = forwardRef(
"py-3 px-3 rounded-lg border border-black/10 dark:border-white/25 flex flex-col max-w-4xl overflow-hidden scroll-pt-32",
left ? "self-start mr-20" : "self-end ml-20"
)}
style={speaker === "user" ? { whiteSpace: "pre-line" } : {}} // Add this line to preserve line breaks
>
<span className={cn("capitalize text-xs")}>{speaker}</span>
<>

View File

@ -32,11 +32,16 @@ export default function ChatPage() {
}}
className="w-full flex items-center justify-center gap-2"
>
<input
<textarea
autoFocus
type="text"
value={question}
onChange={(e) => setQuestion(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault(); // Prevents the newline from being entered in the textarea
if (!isPending) askQuestion(); // Call the submit function here
}
}}
className="w-full p-2 border border-gray-300 dark:border-gray-500 outline-none rounded dark:bg-gray-800"
placeholder="Begin conversation here..."
/>