diff --git a/public/script.js b/public/script.js index 0bd08b2a3..57eb6ee55 100644 --- a/public/script.js +++ b/public/script.js @@ -5408,17 +5408,18 @@ function select_rm_info(type, charId, previousCharId = null) { $('#rm_print_characters_pagination').pagination('go', page); waitUntilCondition(() => document.querySelector(selector) !== null).then(() => { - const element = $(selector).parent().get(0); + const parent = $('#rm_print_characters_block'); + const element = $(selector).parent(); - if (!element) { + if (element.length === 0) { console.log(`Could not find element for character ${charId}`); return; } - element.scrollIntoView({ behavior: 'smooth', block: 'start' }); - $(element).addClass('flash animated'); + parent.scrollTop(element.position().top + parent.scrollTop()); + element.addClass('flash animated'); setTimeout(function () { - $(element).removeClass('flash animated'); + element.removeClass('flash animated'); }, 5000); }); } catch (e) { @@ -5427,16 +5428,29 @@ function select_rm_info(type, charId, previousCharId = null) { } if (type === 'group_create') { - //for groups, ${charId} = data.id from group-chats.js createGroup() - const element = $(`#rm_characters_block [grid="${charId}"]`).get(0); - element.scrollIntoView({ behavior: 'smooth', block: 'start' }); + // Find the page at which the character is located + const charData = getEntitiesList({ doFilter: true }); + const charIndex = charData.findIndex((x) => String(x?.item?.id) === String(charId)); + + if (charIndex === -1) { + console.log(`Could not find group ${charId} in the list`); + return; + } + + const perPage = Number(localStorage.getItem('Characters_PerPage')); + const page = Math.floor(charIndex / perPage) + 1; + $('#rm_print_characters_pagination').pagination('go', page); + const parent = $('#rm_print_characters_block'); + const selector = `#rm_print_characters_block [grid="${charId}"]`; try { - if (element !== undefined || element !== null) { + waitUntilCondition(() => document.querySelector(selector) !== null).then(() => { + const element = $(selector); + parent.scrollTop(element.position().top + parent.scrollTop()); $(element).addClass('flash animated'); setTimeout(function () { $(element).removeClass('flash animated'); }, 5000); - } else { console.log('didnt find the element'); } + }); } catch (e) { console.error(e); } diff --git a/public/scripts/extensions/gallery/index.js b/public/scripts/extensions/gallery/index.js index 4bdde9453..11f3dd4ff 100644 --- a/public/scripts/extensions/gallery/index.js +++ b/public/scripts/extensions/gallery/index.js @@ -7,7 +7,8 @@ import { import { selected_group } from "../../group-chats.js"; import { loadFileToDocument } from "../../utils.js"; import { loadMovingUIState } from '../../power-user.js'; -import { dragElement } from '../../RossAscends-mods.js' +import { dragElement } from '../../RossAscends-mods.js'; +import { registerSlashCommand } from "../../slash-commands.js"; const extensionName = "gallery"; const extensionFolderPath = `scripts/extensions/${extensionName}/`; @@ -386,3 +387,10 @@ function viewWithDragbox(items) { } } + +// Registers a simple command for opening the char gallery. +registerSlashCommand("show-gallery", showGalleryCommand, ["sg"], "Shows the gallery", true, true); + +function showGalleryCommand(args) { + showCharGallery(); +} diff --git a/public/scripts/extensions/quick-reply/index.js b/public/scripts/extensions/quick-reply/index.js index 44360bc34..34b8c7d8a 100644 --- a/public/scripts/extensions/quick-reply/index.js +++ b/public/scripts/extensions/quick-reply/index.js @@ -99,7 +99,14 @@ async function onQuickReplyEnabledInput() { saveSettingsDebounced(); } +// New function to handle input on quickActionEnabled +async function onQuickActionEnabledInput() { + extension_settings.quickReply.quickActionEnabled = $(this).prop('checked'); + saveSettingsDebounced(); +} + async function sendQuickReply(index) { + const existingText = $("#send_textarea").val(); const prompt = extension_settings.quickReply.quickReplySlots[index]?.mes || ''; if (!prompt) { @@ -107,10 +114,29 @@ async function sendQuickReply(index) { return; } - $("#send_textarea").val(prompt); - $("#send_but").trigger('click'); + let newText; + + if (existingText) { + // If existing text, add space after prompt + newText = existingText + ' ' + prompt + ' '; + } else { + // If no existing text, add prompt only (with a trailing space) + newText = prompt + ' '; + } + + $("#send_textarea").val(newText); + + // Set the focus back to the textarea + $("#send_textarea").focus(); + + // Only trigger send button if quickActionEnabled is not checked or + // the prompt starts with '/' + if (!$("#quickActionEnabled").prop('checked') || prompt.startsWith('/')) { + $("#send_but").trigger('click'); + } } + function addQuickReplyBar() { $('#quickReplyBar').remove(); let quickReplyButtonHtml = ''; @@ -309,6 +335,10 @@ jQuery(async () => { Enable Quick Replies +