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:
@ -3503,8 +3503,8 @@ $(document).ready(function () {
|
||||
}
|
||||
chat[chat.length - 1]['swipe_id']++; //make new slot in array
|
||||
// if message has memory attached - remove it to allow regen
|
||||
if (chat[chat.length -1].extra && chat[chat.length -1].extra.memory) {
|
||||
delete chat[chat.length -1].extra.memory;
|
||||
if (chat[chat.length - 1].extra && chat[chat.length - 1].extra.memory) {
|
||||
delete chat[chat.length - 1].extra.memory;
|
||||
}
|
||||
//console.log(chat[chat.length-1]['swipes']);
|
||||
if (parseInt(chat[chat.length - 1]['swipe_id']) === chat[chat.length - 1]['swipes'].length) { //if swipe id of last message is the same as the length of the 'swipes' array
|
||||
@ -5076,12 +5076,13 @@ $(document).ready(function () {
|
||||
$(document).keyup(function (e) {
|
||||
if (e.key === "Escape") {
|
||||
closeMessageEditor();
|
||||
$("#send_textarea").focus();
|
||||
}
|
||||
});
|
||||
|
||||
$("#bg-filter").on("input", function() {
|
||||
$("#bg-filter").on("input", function () {
|
||||
const filterValue = $(this).val().toLowerCase();
|
||||
$("#bg_menu_content > div").each(function() {
|
||||
$("#bg_menu_content > div").each(function () {
|
||||
const $bgContent = $(this);
|
||||
if ($bgContent.attr("title").toLowerCase().includes(filterValue)) {
|
||||
$bgContent.show();
|
||||
|
@ -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,10 +655,23 @@ $("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) => {
|
||||
if (event.ctrlKey && event.key == "Enter") {
|
||||
@ -660,21 +684,21 @@ $("document").ready(function () {
|
||||
//Generate("regenerate");
|
||||
}
|
||||
}
|
||||
if (event.ctrlKey && event.key == "ArrowUp") {
|
||||
//Ctrl+UpArrow for Connect to last server
|
||||
console.log(main_api);
|
||||
if (online_status === "no_connection") {
|
||||
if (main_api == "kobold") {
|
||||
document.getElementById("api_button").click();
|
||||
}
|
||||
if (main_api == "novel") {
|
||||
document.getElementById("api_button_novel").click();
|
||||
}
|
||||
if (main_api == "textgenerationwebui") {
|
||||
document.getElementById("api_button_textgenerationwebui").click();
|
||||
}
|
||||
}
|
||||
}
|
||||
/* if (event.ctrlKey && event.key == "ArrowUp") {
|
||||
//Ctrl+UpArrow for Connect to last server
|
||||
console.log(main_api);
|
||||
if (online_status === "no_connection") {
|
||||
if (main_api == "kobold") {
|
||||
document.getElementById("api_button").click();
|
||||
}
|
||||
if (main_api == "novel") {
|
||||
document.getElementById("api_button_novel").click();
|
||||
}
|
||||
if (main_api == "textgenerationwebui") {
|
||||
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