Files
minne/templates/chat/input_field.html
2025-02-20 21:11:45 +01:00

22 lines
1.0 KiB
HTML

<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>