Merge pull request #2550 from SillyTavern/enable-autoselect-inputs Enable auto-select of input field on popups + Add "auto-select" utility class
Signed| @@ -4098,6 +4098,10 @@ | ||
| 4098 | 4098 | <input id="world_import_dialog" type="checkbox" /> |
| 4099 | 4099 | <small data-i18n="Lorebook Import Dialog">Lorebook Import Dialog</small> |
| 4100 | 4100 | </label> |
| 4101 | + <label data-newbie-hidden class="checkbox_label" for="enable_auto_select_input" title="Enable auto-select of input text in some text fields when clicking/selecting them. Applies to popup input textboxes, and possible other custom input fields." data-i18n="[title]Enable auto-select of input text in some text fields when clicking/selecting them. Applies to popup input textboxes, and possible other custom input fields."> | |
| 4102 | + <input id="enable_auto_select_input" type="checkbox" /> | |
| 4103 | + <small data-i18n="Auto-select Input Text">Auto-select Input Text</small> | |
| 4104 | + </label> | |
| 4101 | 4105 | <label class="checkbox_label" for="restore_user_input" title="Restore unsaved user input on page refresh." data-i18n="[title]Restore unsaved user input on page refresh"> |
| 4102 | 4106 | <input id="restore_user_input" type="checkbox" /> |
| 4103 | 4107 | <small data-i18n="Restore User Input">Restore User Input</small> |
| @@ -4985,7 +4989,7 @@ | ||
| 4985 | 4989 | <div class="popup-crop-wrap"> |
| 4986 | 4990 | <img class="popup-crop-image" src=""> |
| 4987 | 4991 | </div> |
| 4988 | 4992 | <textarea class="popup-input text_pole result-control auto-select" rows="1" data-result="1" data-result-event="submit"></textarea> |
| 4989 | 4993 | <div class="popup-inputs"></div> |
| 4990 | 4994 | <div class="popup-controls"> |
| 4991 | 4995 | <div class="popup-button-ok menu_button result-control" data-result="1" data-i18n="Delete">Delete</div> |
| @@ -10657,6 +10657,15 @@ jQuery(async function () { | ||
| 10657 | 10657 | $(document).on('click', '.open_alternate_greetings', openAlternateGreetings); |
| 10658 | 10658 | /* $('#set_character_world').on('click', openCharacterWorldPopup); */ |
| 10659 | 10659 | |
| 10660 | + $(document).on('focus', 'input.auto-select, textarea.auto-select', function () { | |
| 10661 | + if (!power_user.enable_auto_select_input) return; | |
| 10662 | + const control = $(this)[0]; | |
| 10663 | + if (control instanceof HTMLInputElement || control instanceof HTMLTextAreaElement) { | |
| 10664 | + control.select(); | |
| 10665 | + console.debug('Auto-selecting content of input control', control); | |
| 10666 | + } | |
| 10667 | + }); | |
| 10668 | + | |
| 10660 | 10669 | $(document).keyup(function (e) { |
| 10661 | 10670 | if (e.key === 'Escape') { |
| 10662 | 10671 | const isEditVisible = $('#curEditTextarea').is(':visible'); |
| @@ -202,6 +202,7 @@ let power_user = { | ||
| 202 | 202 | trim_spaces: true, |
| 203 | 203 | relaxed_api_urls: false, |
| 204 | 204 | world_import_dialog: true, |
| 205 | + enable_auto_select_input: false, | |
| 205 | 206 | tag_import_setting: tag_import_setting.ASK, |
| 206 | 207 | disable_group_trimming: false, |
| 207 | 208 | single_line: false, |
| @@ -1596,6 +1597,7 @@ async function loadPowerUserSettings(settings, data) { | ||
| 1596 | 1597 | $('#single_line').prop('checked', power_user.single_line); |
| 1597 | 1598 | $('#relaxed_api_urls').prop('checked', power_user.relaxed_api_urls); |
| 1598 | 1599 | $('#world_import_dialog').prop('checked', power_user.world_import_dialog); |
| 1600 | + $('#enable_auto_select_input').prop('checked', power_user.enable_auto_select_input); | |
| 1599 | 1601 | $('#trim_spaces').prop('checked', power_user.trim_spaces); |
| 1600 | 1602 | $('#continue_on_send').prop('checked', power_user.continue_on_send); |
| 1601 | 1603 | $('#quick_continue').prop('checked', power_user.quick_continue); |
| @@ -3773,6 +3775,12 @@ $(document).ready(() => { | ||
| 3773 | 3775 | saveSettingsDebounced(); |
| 3774 | 3776 | }); |
| 3775 | 3777 | |
| 3778 | + $('#enable_auto_select_input').on('input', function () { | |
| 3779 | + const value = !!$(this).prop('checked'); | |
| 3780 | + power_user.enable_auto_select_input = value; | |
| 3781 | + saveSettingsDebounced(); | |
| 3782 | + }); | |
| 3783 | + | |
| 3776 | 3784 | $('#spoiler_free_mode').on('input', function () { |
| 3777 | 3785 | power_user.spoiler_free_mode = !!$(this).prop('checked'); |
| 3778 | 3786 | switchSpoilerMode(); |