mirror of
https://github.com/open-webui/open-webui
synced 2024-12-28 23:02:25 +00:00
fix: input issue
This commit is contained in:
parent
c4f82309dc
commit
f9e24968e3
@ -592,29 +592,6 @@
|
|||||||
placeholder={placeholder ? placeholder : $i18n.t('Send a Message')}
|
placeholder={placeholder ? placeholder : $i18n.t('Send a Message')}
|
||||||
largeTextAsFile={$settings?.largeTextAsFile ?? false}
|
largeTextAsFile={$settings?.largeTextAsFile ?? false}
|
||||||
bind:value={prompt}
|
bind:value={prompt}
|
||||||
on:enter={async (e) => {
|
|
||||||
const commandsContainerElement =
|
|
||||||
document.getElementById('commands-container');
|
|
||||||
if (commandsContainerElement) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
const commandOptionButton = [
|
|
||||||
...document.getElementsByClassName('selected-command-option-button')
|
|
||||||
]?.at(-1);
|
|
||||||
|
|
||||||
if (commandOptionButton) {
|
|
||||||
commandOptionButton?.click();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prompt !== '') {
|
|
||||||
dispatch('submit', prompt);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
on:keypress={(e) => {
|
|
||||||
e = e.detail.event;
|
|
||||||
}}
|
|
||||||
on:keydown={async (e) => {
|
on:keydown={async (e) => {
|
||||||
e = e.detail.event;
|
e = e.detail.event;
|
||||||
|
|
||||||
@ -657,34 +634,69 @@
|
|||||||
editButton?.click();
|
editButton?.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commandsContainerElement && e.key === 'ArrowUp') {
|
if (commandsContainerElement) {
|
||||||
e.preventDefault();
|
if (commandsContainerElement && e.key === 'ArrowUp') {
|
||||||
commandsElement.selectUp();
|
e.preventDefault();
|
||||||
|
commandsElement.selectUp();
|
||||||
|
|
||||||
const commandOptionButton = [
|
const commandOptionButton = [
|
||||||
...document.getElementsByClassName('selected-command-option-button')
|
...document.getElementsByClassName('selected-command-option-button')
|
||||||
]?.at(-1);
|
]?.at(-1);
|
||||||
commandOptionButton.scrollIntoView({ block: 'center' });
|
commandOptionButton.scrollIntoView({ block: 'center' });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commandsContainerElement && e.key === 'ArrowDown') {
|
if (commandsContainerElement && e.key === 'ArrowDown') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
commandsElement.selectDown();
|
commandsElement.selectDown();
|
||||||
|
|
||||||
const commandOptionButton = [
|
const commandOptionButton = [
|
||||||
...document.getElementsByClassName('selected-command-option-button')
|
...document.getElementsByClassName('selected-command-option-button')
|
||||||
]?.at(-1);
|
]?.at(-1);
|
||||||
commandOptionButton.scrollIntoView({ block: 'center' });
|
commandOptionButton.scrollIntoView({ block: 'center' });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commandsContainerElement && e.key === 'Tab') {
|
if (commandsContainerElement && e.key === 'Tab') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const commandOptionButton = [
|
const commandOptionButton = [
|
||||||
...document.getElementsByClassName('selected-command-option-button')
|
...document.getElementsByClassName('selected-command-option-button')
|
||||||
]?.at(-1);
|
]?.at(-1);
|
||||||
|
|
||||||
commandOptionButton?.click();
|
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
|
||||||
|
if (e.keyCode === 13 && !e.shiftKey) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Submit the prompt when Enter key is pressed
|
||||||
|
if (prompt !== '' && e.keyCode === 13 && !e.shiftKey) {
|
||||||
|
dispatch('submit', prompt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
|
@ -171,11 +171,10 @@
|
|||||||
eventDispatch('focus', { event });
|
eventDispatch('focus', { event });
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
keypress: (view, event) => {
|
keyup: (view, event) => {
|
||||||
eventDispatch('keypress', { event });
|
eventDispatch('keyup', { event });
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
keydown: (view, event) => {
|
keydown: (view, event) => {
|
||||||
// Handle Tab Key
|
// Handle Tab Key
|
||||||
if (event.key === 'Tab') {
|
if (event.key === 'Tab') {
|
||||||
@ -217,22 +216,12 @@
|
|||||||
|
|
||||||
// Handle shift + Enter for a line break
|
// Handle shift + Enter for a line break
|
||||||
if (shiftEnter) {
|
if (shiftEnter) {
|
||||||
if (event.key === 'Enter' && event.shiftKey) {
|
if (event.key === 'Enter' && event.shiftKey && !event.ctrlKey && !event.metaKey) {
|
||||||
editor.commands.setHardBreak(); // Insert a hard break
|
editor.commands.setHardBreak(); // Insert a hard break
|
||||||
view.dispatch(view.state.tr.scrollIntoView()); // Move viewport to the cursor
|
view.dispatch(view.state.tr.scrollIntoView()); // Move viewport to the cursor
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (event.key === 'Enter') {
|
|
||||||
eventDispatch('enter', { event });
|
|
||||||
event.preventDefault();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (event.key === 'Enter') {
|
|
||||||
eventDispatch('enter', { event });
|
|
||||||
event.preventDefault();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eventDispatch('keydown', { event });
|
eventDispatch('keydown', { event });
|
||||||
|
Loading…
Reference in New Issue
Block a user