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
f9351af6
"git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "8b0144cd066c7e7bf749fcf39617fa8e8cf7ea48"
Commit
f9351af6
authored
Jun 03, 2024
by
Timothy J. Baek
Browse files
refac: message input
parent
b4fca046
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
21 deletions
+10
-21
src/lib/components/chat/MessageInput.svelte
src/lib/components/chat/MessageInput.svelte
+10
-21
No files found.
src/lib/components/chat/MessageInput.svelte
View file @
f9351af6
...
@@ -810,10 +810,7 @@
...
@@ -810,10 +810,7 @@
? $i18n.t('Listening...')
? $i18n.t('Listening...')
: $i18n.t('Send a Message')}
: $i18n.t('Send a Message')}
bind:value={prompt}
bind:value={prompt}
on:keypress={(e) => {}}
on:keypress={(e) => {
on:keydown={async (e) => {
// Check if the device is not a mobile device or if it is a mobile device, check if it is not a touch device
// This is to prevent the Enter key from submitting the prompt on mobile devices
if (
if (
!$mobile ||
!$mobile ||
!(
!(
...
@@ -822,28 +819,18 @@
...
@@ -822,28 +819,18 @@
navigator.msMaxTouchPoints > 0
navigator.msMaxTouchPoints > 0
)
)
) {
) {
// Check if Enter is pressed
// Prevent Enter key from creating a new line
// Check if Shift key is not pressed
if (e.key === 'Enter' && !e.shiftKey) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
e.preventDefault();
}
}
const commandOptionButton = [
// Submit the prompt when Enter key is pressed
...document.getElementsByClassName('selected-command-option-button')
if (prompt !== '' && e.key === 'Enter' && !e.shiftKey) {
]?.at(-1);
submitPrompt(prompt, user);
if (!commandOptionButton) {
if (e.key === 'Enter' && !e.shiftKey && prompt !== '') {
submitPrompt(prompt, user);
return;
}
if (e.key === 'Enter' && e.shiftKey && prompt !== '') {
return;
}
}
}
}
}
}}
on:keydown={async (e) => {
const isCtrlPressed = e.ctrlKey || e.metaKey; // metaKey is for Cmd key on Mac
const isCtrlPressed = e.ctrlKey || e.metaKey; // metaKey is for Cmd key on Mac
// Check if Ctrl + R is pressed
// Check if Ctrl + R is pressed
...
@@ -904,7 +891,9 @@
...
@@ -904,7 +891,9 @@
...document.getElementsByClassName('selected-command-option-button')
...document.getElementsByClassName('selected-command-option-button')
]?.at(-1);
]?.at(-1);
if (commandOptionButton) {
if (e.shiftKey) {
prompt = `${prompt}\n`;
} else if (commandOptionButton) {
commandOptionButton?.click();
commandOptionButton?.click();
} else {
} else {
document.getElementById('send-message-button')?.click();
document.getElementById('send-message-button')?.click();
...
...
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