mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'dev' of https://github.com/SillyLossy/TavernAI into dev
This commit is contained in:
@ -5076,6 +5076,7 @@ $(document).ready(function () {
|
||||
$(document).keyup(function (e) {
|
||||
if (e.key === "Escape") {
|
||||
closeMessageEditor();
|
||||
$("#send_textarea").focus();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -588,6 +588,17 @@ $("document").ready(function () {
|
||||
} else { SaveLocal('LNavOpened', 'false'); }
|
||||
});
|
||||
|
||||
var chatbarInFocus = false;
|
||||
$('#send_textarea').focus(function () {
|
||||
chatbarInFocus = true;
|
||||
console.log("chatbatInfocus =" + chatbarInFocus);
|
||||
});
|
||||
|
||||
$('#send_textarea').blur(function () {
|
||||
|
||||
chatbarInFocus = false;
|
||||
console.log("chatbatInfocus =" + chatbarInFocus);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -644,9 +655,22 @@ $("document").ready(function () {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function isInputElementInFocus() {
|
||||
return $(document.activeElement).is(":input");
|
||||
//return $(document.activeElement).is(":input");
|
||||
var focused = $(':focus');
|
||||
if (focused.is('input') || focused.is('textarea')) {
|
||||
if (focused.attr('id') === 'send_textarea') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Additional hotkeys CTRL+ENTER and CTRL+UPARROW
|
||||
document.addEventListener("keydown", (event) => {
|
||||
@ -660,7 +684,7 @@ $("document").ready(function () {
|
||||
//Generate("regenerate");
|
||||
}
|
||||
}
|
||||
if (event.ctrlKey && event.key == "ArrowUp") {
|
||||
/* if (event.ctrlKey && event.key == "ArrowUp") {
|
||||
//Ctrl+UpArrow for Connect to last server
|
||||
console.log(main_api);
|
||||
if (online_status === "no_connection") {
|
||||
@ -674,7 +698,7 @@ $("document").ready(function () {
|
||||
document.getElementById("api_button_textgenerationwebui").click();
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
if (event.ctrlKey && event.key == "ArrowLeft") { //for debug, show all local stored vars
|
||||
CheckLocal();
|
||||
}
|
||||
@ -705,11 +729,13 @@ $("document").ready(function () {
|
||||
$('.swipe_right:last').click();
|
||||
}
|
||||
}
|
||||
if (event.key == "ArrowUp") { //edits last message if chatbar is empty and focused
|
||||
console.log('got uparrow input');
|
||||
|
||||
|
||||
if (event.ctrlKey && event.key == "ArrowUp") { //edits last USER message if chatbar is empty and focused
|
||||
console.log('got ctrl+uparrow input');
|
||||
if (
|
||||
$("#send_textarea").val() === '' &&
|
||||
isInputElementInFocus("#send_textarea") &&
|
||||
chatbarInFocus === true &&
|
||||
$(".swipe_right:last").css('display') === 'flex' &&
|
||||
$("#character_popup").css("display") === "none" &&
|
||||
$("#shadow_select_chat_popup").css("display") === "none"
|
||||
@ -722,5 +748,23 @@ $("document").ready(function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.key == "ArrowUp") { //edits last message if chatbar is empty and focused
|
||||
console.log('got uparrow input');
|
||||
if (
|
||||
$("#send_textarea").val() === '' &&
|
||||
chatbarInFocus === true &&
|
||||
$(".swipe_right:last").css('display') === 'flex' &&
|
||||
$("#character_popup").css("display") === "none" &&
|
||||
$("#shadow_select_chat_popup").css("display") === "none"
|
||||
) {
|
||||
const lastMes = document.querySelector('.last_mes');
|
||||
const editMes = lastMes.querySelector('.mes_block .mes_edit');
|
||||
if (editMes !== null) {
|
||||
$(editMes).click();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user