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
ef4af868
Commit
ef4af868
authored
Jun 01, 2024
by
Timothy J. Baek
Browse files
refac: message new line issue
parent
d993beb1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
src/lib/components/chat/MessageInput.svelte
src/lib/components/chat/MessageInput.svelte
+15
-5
No files found.
src/lib/components/chat/MessageInput.svelte
View file @
ef4af868
...
@@ -817,7 +817,10 @@
...
@@ -817,7 +817,10 @@
? $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 ||
!(
!(
...
@@ -826,15 +829,22 @@
...
@@ -826,15 +829,22 @@
navigator.msMaxTouchPoints > 0
navigator.msMaxTouchPoints > 0
)
)
) {
) {
if (e.keyCode == 13 && !e.shiftKey) {
// Check if Enter is pressed
// Check if Shift key is not pressed
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
e.preventDefault();
}
}
if (prompt !== '' && e.keyCode == 13 && !e.shiftKey) {
if (e.key === 'Enter' && !e.shiftKey && prompt !== '') {
submitPrompt(prompt, user);
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
...
...
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