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 +
@@ -330,7 +360,9 @@ jQuery(async () => {
`; $('#extensions_settings2').append(settingsHtml); - + + // Add event handler for quickActionEnabled + $('#quickActionEnabled').on('input', onQuickActionEnabledInput); $('#quickReplyEnabled').on('input', onQuickReplyEnabledInput); $('#quickReplyNumberOfSlotsApply').on('click', onQuickReplyNumberOfSlotsInput); $("#quickReplyPresetSaveButton").on('click', saveQuickReplyPreset);