mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
replace jQuery's trigger('input') on #send_textarea with native events because jQuery does not dispatch the native event
This commit is contained in:
@ -2406,7 +2406,7 @@ async function processCommands(message) {
|
||||
const currentText = String($('#send_textarea').val());
|
||||
|
||||
if (previousText === currentText) {
|
||||
$('#send_textarea').val(result.newText).trigger('input');
|
||||
$('#send_textarea').val(result.newText)[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
}
|
||||
|
||||
// interrupt generation if the input was nothing but a command
|
||||
@ -2690,7 +2690,7 @@ class StreamingProcessor {
|
||||
let messageId = -1;
|
||||
|
||||
if (this.type == 'impersonate') {
|
||||
$('#send_textarea').val('').trigger('input');
|
||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
}
|
||||
else {
|
||||
await saveReply(this.type, text, true);
|
||||
@ -2726,7 +2726,7 @@ class StreamingProcessor {
|
||||
}
|
||||
|
||||
if (isImpersonate) {
|
||||
$('#send_textarea').val(processedText).trigger('input');
|
||||
$('#send_textarea').val(processedText)[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
}
|
||||
else {
|
||||
let currentTime = new Date();
|
||||
@ -3073,7 +3073,7 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
|
||||
const interruptedByCommand = await processCommands(String($('#send_textarea').val()));
|
||||
|
||||
if (interruptedByCommand) {
|
||||
//$("#send_textarea").val('').trigger('input');
|
||||
//$("#send_textarea").val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
unblockGeneration(type);
|
||||
return Promise.resolve();
|
||||
}
|
||||
@ -3159,7 +3159,7 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
|
||||
if (type !== 'regenerate' && type !== 'swipe' && type !== 'quiet' && !isImpersonate && !dryRun) {
|
||||
is_send_press = true;
|
||||
textareaText = String($('#send_textarea').val());
|
||||
$('#send_textarea').val('').trigger('input');
|
||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
} else {
|
||||
textareaText = '';
|
||||
if (chat.length && chat[chat.length - 1]['is_user']) {
|
||||
@ -4094,7 +4094,7 @@ async function Generate(type, { automatic_trigger, force_name2, quiet_prompt, qu
|
||||
|
||||
if (getMessage.length > 0) {
|
||||
if (isImpersonate) {
|
||||
$('#send_textarea').val(getMessage).trigger('input');
|
||||
$('#send_textarea').val(getMessage)[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
generatedPromptCache = '';
|
||||
await eventSource.emit(event_types.IMPERSONATE_READY, getMessage);
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ function restoreUserInput() {
|
||||
|
||||
const userInput = LoadLocal('userInput');
|
||||
if (userInput) {
|
||||
$('#send_textarea').val(userInput).trigger('input');
|
||||
$('#send_textarea').val(userInput)[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -804,7 +804,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
||||
const bias = getBiasStrings(userInput, type);
|
||||
await sendMessageAsUser(userInput, bias.messageBias);
|
||||
await saveChatConditional();
|
||||
$('#send_textarea').val('').trigger('input');
|
||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
}
|
||||
|
||||
// now the real generation begins: cycle through every activated character
|
||||
|
@ -236,7 +236,7 @@ export function processChatSlashCommands() {
|
||||
}
|
||||
|
||||
function setInputCallback(_, value) {
|
||||
$('#send_textarea').val(value || '').trigger('input');
|
||||
$('#send_textarea').val(value || '')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -422,7 +422,7 @@ async function runCallback(args, name) {
|
||||
}
|
||||
|
||||
function abortCallback() {
|
||||
$('#send_textarea').val('').trigger('input');
|
||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
throw new Error('/abort command executed');
|
||||
}
|
||||
|
||||
@ -540,7 +540,7 @@ async function generateRawCallback(args, value) {
|
||||
}
|
||||
|
||||
// Prevent generate recursion
|
||||
$('#send_textarea').val('').trigger('input');
|
||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
const lock = isTrueBoolean(args?.lock);
|
||||
const as = args?.as || 'system';
|
||||
const quietToLoud = as === 'char';
|
||||
@ -570,7 +570,7 @@ async function generateCallback(args, value) {
|
||||
}
|
||||
|
||||
// Prevent generate recursion
|
||||
$('#send_textarea').val('').trigger('input');
|
||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
const lock = isTrueBoolean(args?.lock);
|
||||
const as = args?.as || 'system';
|
||||
const quietToLoud = as === 'char';
|
||||
@ -706,7 +706,7 @@ async function deleteSwipeCallback(_, arg) {
|
||||
|
||||
async function askCharacter(_, text) {
|
||||
// Prevent generate recursion
|
||||
$('#send_textarea').val('').trigger('input');
|
||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
|
||||
// Not supported in group chats
|
||||
// TODO: Maybe support group chats?
|
||||
@ -1017,7 +1017,7 @@ async function triggerGenerationCallback(args, value) {
|
||||
}
|
||||
|
||||
// Prevent generate recursion
|
||||
$('#send_textarea').val('').trigger('input');
|
||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
|
||||
let chid = undefined;
|
||||
|
||||
@ -1157,7 +1157,7 @@ function continueChatCallback(_, prompt) {
|
||||
}
|
||||
|
||||
// Prevent infinite recursion
|
||||
$('#send_textarea').val('').trigger('input');
|
||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
$('#option_continue').trigger('click', { fromSlashCommand: true, additionalPrompt: prompt });
|
||||
}, 1);
|
||||
|
||||
@ -1165,7 +1165,7 @@ function continueChatCallback(_, prompt) {
|
||||
}
|
||||
|
||||
export async function generateSystemMessage(_, prompt) {
|
||||
$('#send_textarea').val('').trigger('input');
|
||||
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
|
||||
|
||||
if (!prompt) {
|
||||
console.warn('WARN: No prompt provided for /sysgen command');
|
||||
|
Reference in New Issue
Block a user