mirror of
https://github.com/open-webui/open-webui
synced 2024-11-06 08:56:39 +00:00
refac: message input
This commit is contained in:
parent
b4fca046a8
commit
f9351af6a3
@ -810,10 +810,7 @@
|
||||
? $i18n.t('Listening...')
|
||||
: $i18n.t('Send a Message')}
|
||||
bind:value={prompt}
|
||||
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
|
||||
on:keypress={(e) => {
|
||||
if (
|
||||
!$mobile ||
|
||||
!(
|
||||
@ -822,28 +819,18 @@
|
||||
navigator.msMaxTouchPoints > 0
|
||||
)
|
||||
) {
|
||||
// Check if Enter is pressed
|
||||
// Check if Shift key is not pressed
|
||||
// Prevent Enter key from creating a new line
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
const commandOptionButton = [
|
||||
...document.getElementsByClassName('selected-command-option-button')
|
||||
]?.at(-1);
|
||||
|
||||
if (!commandOptionButton) {
|
||||
if (e.key === 'Enter' && !e.shiftKey && prompt !== '') {
|
||||
submitPrompt(prompt, user);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.key === 'Enter' && e.shiftKey && prompt !== '') {
|
||||
return;
|
||||
}
|
||||
// Submit the prompt when Enter key is pressed
|
||||
if (prompt !== '' && e.key === 'Enter' && !e.shiftKey) {
|
||||
submitPrompt(prompt, user);
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
on:keydown={async (e) => {
|
||||
const isCtrlPressed = e.ctrlKey || e.metaKey; // metaKey is for Cmd key on Mac
|
||||
|
||||
// Check if Ctrl + R is pressed
|
||||
@ -904,7 +891,9 @@
|
||||
...document.getElementsByClassName('selected-command-option-button')
|
||||
]?.at(-1);
|
||||
|
||||
if (commandOptionButton) {
|
||||
if (e.shiftKey) {
|
||||
prompt = `${prompt}\n`;
|
||||
} else if (commandOptionButton) {
|
||||
commandOptionButton?.click();
|
||||
} else {
|
||||
document.getElementById('send-message-button')?.click();
|
||||
|
Loading…
Reference in New Issue
Block a user