mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-09 08:30:13 +01:00
Make "send message from chat box" into a function
Right now all it does is handle returning if there's already a message being generated, but I'll extend it with more logic that I want to move out of Generate().
This commit is contained in:
parent
1029ad90a2
commit
7899549754
@ -1472,6 +1472,14 @@ export async function reloadCurrentChat() {
|
|||||||
showSwipeButtons();
|
showSwipeButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the message currently typed into the chat box.
|
||||||
|
*/
|
||||||
|
export function sendTextareaMessage() {
|
||||||
|
if (is_send_press) return;
|
||||||
|
Generate();
|
||||||
|
}
|
||||||
|
|
||||||
function messageFormatting(mes, ch_name, isSystem, isUser) {
|
function messageFormatting(mes, ch_name, isSystem, isUser) {
|
||||||
if (!mes) {
|
if (!mes) {
|
||||||
return '';
|
return '';
|
||||||
@ -7971,12 +7979,7 @@ jQuery(async function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#send_but').on('click', function () {
|
$('#send_but').on('click', function () {
|
||||||
if (is_send_press == false) {
|
sendTextareaMessage();
|
||||||
// This prevents from running /trigger command with a send button
|
|
||||||
// But send on Enter doesn't set is_send_press (it is done by the Generate itself)
|
|
||||||
// is_send_press = true;
|
|
||||||
Generate();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//menu buttons setup
|
//menu buttons setup
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
Generate,
|
|
||||||
characters,
|
characters,
|
||||||
online_status,
|
online_status,
|
||||||
main_api,
|
main_api,
|
||||||
@ -18,6 +17,7 @@ import {
|
|||||||
menu_type,
|
menu_type,
|
||||||
substituteParams,
|
substituteParams,
|
||||||
callPopup,
|
callPopup,
|
||||||
|
sendTextareaMessage,
|
||||||
} from '../script.js';
|
} from '../script.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -954,9 +954,9 @@ export function initRossMods() {
|
|||||||
//Enter to send when send_textarea in focus
|
//Enter to send when send_textarea in focus
|
||||||
if ($(':focus').attr('id') === 'send_textarea') {
|
if ($(':focus').attr('id') === 'send_textarea') {
|
||||||
const sendOnEnter = shouldSendOnEnter();
|
const sendOnEnter = shouldSendOnEnter();
|
||||||
if (!event.shiftKey && !event.ctrlKey && !event.altKey && event.key == 'Enter' && is_send_press == false && sendOnEnter) {
|
if (!event.shiftKey && !event.ctrlKey && !event.altKey && event.key == 'Enter' && sendOnEnter) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
Generate();
|
sendTextareaMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($(':focus').attr('id') === 'dialogue_popup_input' && !isMobile()) {
|
if ($(':focus').attr('id') === 'dialogue_popup_input' && !isMobile()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user