Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
cc471597
Commit
cc471597
authored
Mar 03, 2024
by
Carlos Daniel Vilaseca
Browse files
rf: message input dom queries
parent
fe19f125
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
13 deletions
+8
-13
src/lib/components/chat/MessageInput.svelte
src/lib/components/chat/MessageInput.svelte
+8
-13
No files found.
src/lib/components/chat/MessageInput.svelte
View file @
cc471597
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
export let suggestionPrompts = [];
export let suggestionPrompts = [];
export let autoScroll = true;
export let autoScroll = true;
let chatTextArea:HTMLTextAreaElement
let filesInputElement;
let filesInputElement;
let promptsElement;
let promptsElement;
...
@@ -43,11 +43,9 @@
...
@@ -43,11 +43,9 @@
let speechRecognition;
let speechRecognition;
$: if (prompt) {
$: if (prompt) {
const chatInput = document.getElementById('chat-textarea');
if (chatTextArea) {
chatTextArea.style.height = '';
if (chatInput) {
chatTextArea.style.height = Math.min(chatTextArea.scrollHeight, 200) + 'px';
chatInput.style.height = '';
chatInput.style.height = Math.min(chatInput.scrollHeight, 200) + 'px';
}
}
}
}
...
@@ -86,9 +84,7 @@
...
@@ -86,9 +84,7 @@
if (res) {
if (res) {
prompt = res.text;
prompt = res.text;
await tick();
await tick();
chatTextArea?.focus();
const inputElement = document.getElementById('chat-textarea');
inputElement?.focus();
if (prompt !== '' && $settings?.speechAutoSend === true) {
if (prompt !== '' && $settings?.speechAutoSend === true) {
submitPrompt(prompt, user);
submitPrompt(prompt, user);
...
@@ -191,8 +187,7 @@
...
@@ -191,8 +187,7 @@
prompt = `${prompt}${transcript}`;
prompt = `${prompt}${transcript}`;
await tick();
await tick();
const inputElement = document.getElementById('chat-textarea');
chatTextArea?.focus();
inputElement?.focus();
// Restart the inactivity timeout
// Restart the inactivity timeout
timeoutId = setTimeout(() => {
timeoutId = setTimeout(() => {
...
@@ -294,8 +289,7 @@
...
@@ -294,8 +289,7 @@
};
};
onMount(() => {
onMount(() => {
const chatInput = document.getElementById('chat-textarea');
window.setTimeout(() => chatTextArea?.focus(), 0);
window.setTimeout(() => chatInput?.focus(), 0);
const dropZone = document.querySelector('body');
const dropZone = document.querySelector('body');
...
@@ -663,6 +657,7 @@
...
@@ -663,6 +657,7 @@
<textarea
<textarea
id="chat-textarea"
id="chat-textarea"
bind:this={chatTextArea}
class=" dark:bg-gray-900 dark:text-gray-100 outline-none w-full py-3 px-3 {fileUploadEnabled
class=" dark:bg-gray-900 dark:text-gray-100 outline-none w-full py-3 px-3 {fileUploadEnabled
? ''
? ''
: ' pl-4'} rounded-xl resize-none h-[48px]"
: ' pl-4'} rounded-xl resize-none h-[48px]"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment