mirror of
https://github.com/perstarkse/minne.git
synced 2026-06-12 17:24:26 +02:00
7b850769c9
Avoid nested forms in the scratchpad editor, centralize modal lifecycle in modal.js, return HTMX partials from archive, and add template compile plus layout snapshots.
32 lines
1.4 KiB
HTML
32 lines
1.4 KiB
HTML
{% include "chat/streaming_response.html" %}
|
|
<!-- OOB swap targeting the form element directly -->
|
|
<form id="chat-form" hx-post="/chat/{{conversation.id}}" hx-target="#chat_container" hx-swap="beforeend"
|
|
class="relative flex gap-2" hx-swap-oob="true"
|
|
hx-on::after-request="if(event.detail.successful) document.getElementById('chat-input').value=''">
|
|
<textarea autofocus required name="content" placeholder="Type your message..." rows="2"
|
|
class="nb-input h-24 pr-8 pl-2 pt-2 pb-2 flex-grow resize-none" id="chat-input"
|
|
hx-on:keydown="if(event.key==='Enter'&&!event.shiftKey){event.preventDefault();htmx.trigger('#chat-form','submit')}"></textarea>
|
|
<button type="submit" class="absolute p-2 cursor-pointer right-0.5 btn-ghost btn-sm top-1">
|
|
{% include "icons/send_icon.html" %}
|
|
</button>
|
|
<label for="my-drawer-2" class="absolute cursor-pointer top-9 right-0.5 p-2 drawer-button xl:hidden z-20 ">
|
|
{% include "icons/hamburger_icon.html" %}
|
|
</label>
|
|
</form>
|
|
<script>
|
|
(function () {
|
|
const refreshSidebarAfterFirstResponse = function (e) {
|
|
if (!e.target.closest('[data-message-id]')) return;
|
|
|
|
htmx.ajax('GET', '/chat/sidebar', {
|
|
target: '.drawer-side',
|
|
swap: 'outerHTML'
|
|
});
|
|
|
|
document.body.removeEventListener('htmx:sseClose', refreshSidebarAfterFirstResponse);
|
|
};
|
|
|
|
document.body.addEventListener('htmx:sseClose', refreshSidebarAfterFirstResponse);
|
|
})();
|
|
</script>
|