Merge pull request #1113 from Hakirus/staging

Quick Reply Mod
This commit is contained in:
RossAscends 2023-09-08 09:30:19 +09:00 committed by GitHub
commit 44ba1cba59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 3 deletions

View File

@ -99,7 +99,14 @@ async function onQuickReplyEnabledInput() {
saveSettingsDebounced(); saveSettingsDebounced();
} }
// New function to handle input on quickActionEnabled
async function onQuickActionEnabledInput() {
extension_settings.quickReply.quickActionEnabled = $(this).prop('checked');
saveSettingsDebounced();
}
async function sendQuickReply(index) { async function sendQuickReply(index) {
const existingText = $("#send_textarea").val();
const prompt = extension_settings.quickReply.quickReplySlots[index]?.mes || ''; const prompt = extension_settings.quickReply.quickReplySlots[index]?.mes || '';
if (!prompt) { if (!prompt) {
@ -107,10 +114,29 @@ async function sendQuickReply(index) {
return; return;
} }
$("#send_textarea").val(prompt); let newText;
$("#send_but").trigger('click');
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() { function addQuickReplyBar() {
$('#quickReplyBar').remove(); $('#quickReplyBar').remove();
let quickReplyButtonHtml = ''; let quickReplyButtonHtml = '';
@ -309,6 +335,10 @@ jQuery(async () => {
<input id="quickReplyEnabled" type="checkbox" /> <input id="quickReplyEnabled" type="checkbox" />
Enable Quick Replies Enable Quick Replies
</label> </label>
<label class="checkbox_label marginBot10 wide100p flexnowrap">
<input id="quickActionEnabled" type="checkbox" />
Disable Send / Insert In User Input
</label>
<div class="flex-container flexnowrap wide100p"> <div class="flex-container flexnowrap wide100p">
<select id="quickReplyPresets" name="quickreply-preset"> <select id="quickReplyPresets" name="quickreply-preset">
</select> </select>
@ -330,7 +360,9 @@ jQuery(async () => {
</div>`; </div>`;
$('#extensions_settings2').append(settingsHtml); $('#extensions_settings2').append(settingsHtml);
// Add event handler for quickActionEnabled
$('#quickActionEnabled').on('input', onQuickActionEnabledInput);
$('#quickReplyEnabled').on('input', onQuickReplyEnabledInput); $('#quickReplyEnabled').on('input', onQuickReplyEnabledInput);
$('#quickReplyNumberOfSlotsApply').on('click', onQuickReplyNumberOfSlotsInput); $('#quickReplyNumberOfSlotsApply').on('click', onQuickReplyNumberOfSlotsInput);
$("#quickReplyPresetSaveButton").on('click', saveQuickReplyPreset); $("#quickReplyPresetSaveButton").on('click', saveQuickReplyPreset);