mirror of
https://github.com/perstarkse/minne.git
synced 2026-04-27 03:08:41 +02:00
wip: chat interface
This commit is contained in:
22
templates/chat/input_field.html
Normal file
22
templates/chat/input_field.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<form hx-post="/chat/{{conversation_id}}" hx-target="#chat_container" hx-swap="afterend" class="relative flex gap-2"
|
||||
id="chat-form">
|
||||
<textarea name="content" placeholder="Type your message..." rows="2"
|
||||
class="textarea rounded-t-2xl rounded-b-none border-2 flex-grow resize-none" id="chat-input"></textarea>
|
||||
<button type="submit" class="absolute p-2 cursor-pointer right-0.5 btn-ghost btn-sm top-2">{% include
|
||||
"icons/send_icon.html" %}
|
||||
</button>
|
||||
<label for="my-drawer-2" class="absolute cursor-pointer top-10 right-0.5 p-2 drawer-button xl:hidden z-20 ">
|
||||
{% include "icons/hamburger_icon.html" %}
|
||||
</label>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
document.getElementById('chat-input').addEventListener('keydown', function (e) {
|
||||
// Check if Enter is pressed without Shift
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
e.preventDefault(); // Prevent default Enter behavior (new line)
|
||||
document.getElementById('chat-form').submit(); // Submit the form
|
||||
}
|
||||
// Shift + Enter will naturally create a new line due to browser default behavior
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user