{#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 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'}
{:else} { files.splice(fileIdx, 1); files = files; }} on:click={() => { console.log(file); }} /> {/if} {/each}
{/if}
{#key $settings?.richTextInput} 0 || navigator.msMaxTouchPoints > 0 )} largeTextAsFile={$settings?.largeTextAsFile ?? false} floatingMenuPlacement={'top-start'} {suggestions} onChange={(e) => { const { md } = e; content = md; command = getCommand(); }} on:keydown={async (e) => { e = e.detail.event; const isCtrlPressed = e.ctrlKey || e.metaKey; // metaKey is for Cmd key on Mac const suggestionsContainerElement = document.getElementById('suggestions-container'); if (!suggestionsContainerElement) { if ( !$mobile || !( 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0 ) ) { // Prevent Enter key from creating a new line // Uses keyCode '13' for Enter key for chinese/japanese keyboards if (e.keyCode === 13 && !e.shiftKey) { e.preventDefault(); } // Submit the content when Enter key is pressed if (content !== '' && e.keyCode === 13 && !e.shiftKey) { 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.indexOf('image') !== -1) { const blob = item.getAsFile(); const reader = new FileReader(); reader.onload = function (e) { files = [ ...files, { type: 'image', url: `${e.target.result}` } ]; }; reader.readAsDataURL(blob); } else if (item?.kind === 'file') { const file = item.getAsFile(); if (file) { const _files = [file]; await inputFilesHandler(_files); e.preventDefault(); } } } } }} /> {/key}
{#if acceptFiles} { filesInputElement.click(); }} > {/if}
{#if content === ''} {/if}
{#if inputLoading && onStop}
{:else}
{/if}
{/if}
{/if}