{#if acceptFiles} { if (inputFiles && inputFiles.length > 0) { inputFilesHandler(Array.from(inputFiles)); } else { toast.error($i18n.t(`File not found.`)); } filesInputElement.value = ''; }} /> {/if} { inputVariableValues = { ...inputVariableValues, ...variableValues }; replaceVariables(inputVariableValues); }} /> {#if scrollEnd === false} { scrollEnd = true; scrollToBottom(); }} > {/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 files.length > 0} {#each files as file, fileIdx} {#if file.type === 'image'} { files.splice(fileIdx, 1); files = files; }} > {:else} { files.splice(fileIdx, 1); files = files; }} on:click={() => { console.log(file); }} /> {/if} {/each} {/if} 0 || navigator.msMaxTouchPoints > 0 ))} largeTextAsFile={$settings?.largeTextAsFile ?? false} 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 commandsContainerElement = document.getElementById('commands-container'); if (commandsContainerElement) { if (commandsContainerElement && e.key === 'ArrowUp') { e.preventDefault(); commandsElement.selectUp(); const commandOptionButton = [ ...document.getElementsByClassName('selected-command-option-button') ]?.at(-1); commandOptionButton.scrollIntoView({ block: 'center' }); } if (commandsContainerElement && e.key === 'ArrowDown') { e.preventDefault(); commandsElement.selectDown(); const commandOptionButton = [ ...document.getElementsByClassName('selected-command-option-button') ]?.at(-1); commandOptionButton.scrollIntoView({ block: 'center' }); } if (commandsContainerElement && e.key === 'Tab') { e.preventDefault(); const commandOptionButton = [ ...document.getElementsByClassName('selected-command-option-button') ]?.at(-1); commandOptionButton?.click(); } if (commandsContainerElement && e.key === 'Enter') { e.preventDefault(); const commandOptionButton = [ ...document.getElementsByClassName('selected-command-option-button') ]?.at(-1); if (commandOptionButton) { commandOptionButton?.click(); } else { document.getElementById('send-message-button')?.click(); } } } else { 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'); } }} on:paste={async (e) => { e = e.detail.event; console.info(e); }} /> {#if acceptFiles} { filesInputElement.click(); }} > {/if} {#if content === ''} { try { let stream = await navigator.mediaDevices .getUserMedia({ audio: true }) .catch(function (err) { toast.error( $i18n.t(`Permission denied when accessing microphone: {{error}}`, { error: err }) ); return null; }); if (stream) { recording = true; const tracks = stream.getTracks(); tracks.forEach((track) => track.stop()); } stream = null; } catch { toast.error($i18n.t('Permission denied when accessing microphone')); } }} aria-label="Voice Input" > {/if} {#if inputLoading && onStop} { onStop(); }} > {:else} {/if} {/if}