{#if loaded} {#if acceptFiles} { if (inputFiles && inputFiles.length > 0) { inputFilesHandler(Array.from(inputFiles)); } else { toast.error($i18n.t(`File not found.`)); } filesInputElement.value = ''; }} /> {/if}
{#if scrollEnd === false}
{/if}
{#if typingUsers.length > 0}
{typingUsers.map((user) => user.name).join(', ')} {$i18n.t('is typing...')}
{/if}
{#if recording} { recording = false; await tick(); if (chatInputElement) { chatInputElement.focus(); } }} onConfirm={async (data) => { const { text, filename } = data; recording = false; await tick(); insertTextAtCursor(text); await tick(); if (chatInputElement) { chatInputElement.focus(); } }} /> {:else}
{ submitHandler(); }} > {#if messageQueue.length > 0}
{#each messageQueue as entry (entry.id)} processNextInQueue(queueKey, messageId)} onEdit={content || files.length || replyToMessage ? undefined : editQueuedMessage} onDelete={deleteQueuedMessage} /> {/each}
{/if} {#if replyToMessage !== null}
{$i18n.t('Replying to {{NAME}}', { NAME: replyToMessage?.meta?.model_name ?? replyToMessage.user.name })}
{/if} {#if files.length > 0}
{#each files as file, fileIdx} {#if file.type === 'image' || (file?.content_type ?? '').startsWith('image/')} {@const fileUrl = file.url.startsWith('data') || file.url.startsWith('http') ? file.url : `${WEBUI_API_BASE_URL}/files/${file.url}${file?.content_type ? '/content' : ''}`}
{:else} { files.splice(fileIdx, 1); files = files; }} on:click={() => { console.log(file); }} /> {/if} {/each}
{/if}
{#key $settings?.richTextInput && $settings?.showFormattingToolbar} 0 || navigator.msMaxTouchPoints > 0 )} largeTextAsFile={($settings?.largeTextAsFile ?? false) && !shiftKey} floatingMenuPlacement={'top-start'} {suggestions} on:pasted={resolveInputMentions} onChange={(e) => { const { md } = e; content = md; command = getCommand(); }} on:keydown={async (e) => { e = e.detail.event; // IME confirmation must finish before a shortcut can send and clear the editor. if (e.isComposing || e.keyCode === 229 || inputEditor?.view.composing) return; const isCtrlPressed = e.ctrlKey || e.metaKey; // metaKey is for Cmd key on Mac const suggestionsContainerElement = document.getElementById('suggestions-container'); if (!suggestionsContainerElement) { if ( e.key === 'ArrowUp' && !e.isComposing && !isCtrlPressed && !e.shiftKey && !e.altKey && !disabled && content === '' && files.length === 0 ) { const message = messages?.find( (message) => message.user_id === $user?.id && !message.temp_id ); if (message) { const messageId = parentId ? `${parentId}-${message.id}` : message.id; const editButton = document.getElementById( `edit-message-${messageId}` ); if (editButton) { e.preventDefault(); editButton.click(); } } } if ( !$mobile || !( 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0 ) ) { // Uses keyCode '13' for Enter key for chinese/japanese keyboards const enterPressed = ($settings?.ctrlEnterToSend ?? false) ? (e.key === 'Enter' || e.keyCode === 13) && isCtrlPressed : (e.key === 'Enter' || e.keyCode === 13) && !e.shiftKey; if (enterPressed) { e.preventDefault(); if (content !== '' || files.length > 0) { submitHandler(); } } } } if (e.key === 'Escape') { console.info('Escape'); replyToMessage = null; } }} on:paste={async (e) => { e = e.detail.event; console.log(e); const clipboardData = e.clipboardData || window.clipboardData; if (clipboardData && clipboardData.items) { for (const item of clipboardData.items) { if (item.type === 'text/plain') { if (($settings?.largeTextAsFile ?? false) && !shiftKey) { const text = clipboardData.getData('text/plain'); if (text.length > PASTED_TEXT_CHARACTER_LIMIT) { e.preventDefault(); const blob = new Blob([text], { type: 'text/plain' }); const file = new File([blob], `Pasted_Text_${Date.now()}.txt`, { type: 'text/plain' }); await uploadFileHandler(file); } } } else { const file = item.getAsFile(); if (file) { await inputFilesHandler([file]); e.preventDefault(); } } } } }} /> {/key}
{#if acceptFiles} { filesInputElement.click(); }} > {/if}
{#if content === ''} {/if}
{#if inputLoading && onStop}
{:else}
{/if}
{/if}
{/if}