mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Better input inject Quick Reply (#1255)
* Force open Char WI with Shift QoL - Force open character WI selector menu if icon clicked with Shift. * Update world-info.js (revert personal new WI pos preference) * Fix element widths * Fix event typing * Update index.js * Update index.js * change Prompt to Input this makes it more clear what it does(i think) --------- Co-authored-by: valden80 <111227649+valden80@users.noreply.github.com> Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
		| @@ -15,8 +15,9 @@ const defaultSettings = { | |||||||
|     quickReplyEnabled: false, |     quickReplyEnabled: false, | ||||||
|     numberOfSlots: 5, |     numberOfSlots: 5, | ||||||
|     quickReplySlots: [], |     quickReplySlots: [], | ||||||
|     placeBeforePromptEnabled: false, |     placeBeforeInputEnabled: false, | ||||||
|     quickActionEnabled: false, |     quickActionEnabled: false, | ||||||
|  |     AutoInputInject: true | ||||||
| } | } | ||||||
|  |  | ||||||
| //method from worldinfo | //method from worldinfo | ||||||
| @@ -77,8 +78,9 @@ async function loadSettings(type) { | |||||||
|  |  | ||||||
|     $('#quickReplyEnabled').prop('checked', extension_settings.quickReply.quickReplyEnabled); |     $('#quickReplyEnabled').prop('checked', extension_settings.quickReply.quickReplyEnabled); | ||||||
|     $('#quickReplyNumberOfSlots').val(extension_settings.quickReply.numberOfSlots); |     $('#quickReplyNumberOfSlots').val(extension_settings.quickReply.numberOfSlots); | ||||||
|     $('#placeBeforePromptEnabled').prop('checked', extension_settings.quickReply.placeBeforePromptEnabled); |     $('#placeBeforeInputEnabled').prop('checked', extension_settings.quickReply.placeBeforeInputEnabled); | ||||||
|     $('#quickActionEnabled').prop('checked', extension_settings.quickReply.quickActionEnabled); |     $('#quickActionEnabled').prop('checked', extension_settings.quickReply.quickActionEnabled); | ||||||
|  |     $('#AutoInputInject').prop('checked', extension_settings.quickReply.AutoInputInject); | ||||||
| } | } | ||||||
|  |  | ||||||
| function onQuickReplyInput(id) { | function onQuickReplyInput(id) { | ||||||
| @@ -109,8 +111,13 @@ async function onQuickActionEnabledInput() { | |||||||
|     saveSettingsDebounced(); |     saveSettingsDebounced(); | ||||||
| } | } | ||||||
|  |  | ||||||
| async function onPlaceBeforePromptEnabledInput() { | async function onPlaceBeforeInputEnabledInput() { | ||||||
|     extension_settings.quickReply.placeBeforePromptEnabled = !!$(this).prop('checked'); |     extension_settings.quickReply.placeBeforeInputEnabled = !!$(this).prop('checked'); | ||||||
|  |     saveSettingsDebounced(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | async function onAutoInputInject() { | ||||||
|  |     extension_settings.quickReply.AutoInputInject = !!$(this).prop('checked'); | ||||||
|     saveSettingsDebounced(); |     saveSettingsDebounced(); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -125,16 +132,15 @@ async function sendQuickReply(index) { | |||||||
|  |  | ||||||
|     let newText; |     let newText; | ||||||
|  |  | ||||||
|     if (existingText) { |     if (existingText && extension_settings.quickReply.AutoInputInject){ | ||||||
|         // If existing text, add space after prompt |         if (extension_settings.quickReply.placeBeforeInputEnabled) { | ||||||
|         if (extension_settings.quickReply.placeBeforePromptEnabled) { |  | ||||||
|             newText = `${prompt} ${existingText} `; |             newText = `${prompt} ${existingText} `; | ||||||
|         } else { |         } else { | ||||||
|             newText = `${existingText} ${prompt} `; |             newText = `${existingText} ${prompt} `; | ||||||
|         } |         } | ||||||
|     } else { |     } else { | ||||||
|         // If no existing text, add prompt only (with a trailing space) |         // If no existing text and placeBeforeInputEnabled false, add prompt only (with a trailing space) | ||||||
|         newText = prompt + ' '; |         newText = `${prompt} `; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     newText = substituteParams(newText); |     newText = substituteParams(newText); | ||||||
| @@ -355,8 +361,12 @@ jQuery(async () => { | |||||||
|                         Disable Send / Insert In User Input |                         Disable Send / Insert In User Input | ||||||
|                 </label> |                 </label> | ||||||
|                 <label class="checkbox_label marginBot10"> |                 <label class="checkbox_label marginBot10"> | ||||||
|                     <input id="placeBeforePromptEnabled" type="checkbox" /> |                     <input id="placeBeforeInputEnabled" type="checkbox" /> | ||||||
|                         Place Quick-reply before the Prompt |                         Place Quick-reply before the Input | ||||||
|  |                 </label> | ||||||
|  |                 <label class="checkbox_label marginBot10"> | ||||||
|  |                     <input id="AutoInputInject" type="checkbox" /> | ||||||
|  |                         Inject user input automatically (If disabled, use {{input}} macro for manual injection) | ||||||
|                 </label> |                 </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"> | ||||||
| @@ -382,7 +392,8 @@ jQuery(async () => { | |||||||
|      |      | ||||||
|     // Add event handler for quickActionEnabled |     // Add event handler for quickActionEnabled | ||||||
|     $('#quickActionEnabled').on('input', onQuickActionEnabledInput); |     $('#quickActionEnabled').on('input', onQuickActionEnabledInput); | ||||||
|     $('#placeBeforePromptEnabled').on('input', onPlaceBeforePromptEnabledInput); |     $('#placeBeforeInputEnabled').on('input', onPlaceBeforeInputEnabledInput); | ||||||
|  |     $('#AutoInputInject').on('input', onAutoInputInject); | ||||||
|     $('#quickReplyEnabled').on('input', onQuickReplyEnabledInput); |     $('#quickReplyEnabled').on('input', onQuickReplyEnabledInput); | ||||||
|     $('#quickReplyNumberOfSlotsApply').on('click', onQuickReplyNumberOfSlotsInput); |     $('#quickReplyNumberOfSlotsApply').on('click', onQuickReplyNumberOfSlotsInput); | ||||||
|     $("#quickReplyPresetSaveButton").on('click', saveQuickReplyPreset); |     $("#quickReplyPresetSaveButton").on('click', saveQuickReplyPreset); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user