Merge pull request #2550 from SillyTavern/enable-autoselect-inputs
Enable auto-select of input field on popups + Add "auto-select" utility class
This commit is contained in:
commit
08e83c3ae8
|
@ -4098,6 +4098,10 @@
|
|||
<input id="world_import_dialog" type="checkbox" />
|
||||
<small data-i18n="Lorebook Import Dialog">Lorebook Import Dialog</small>
|
||||
</label>
|
||||
<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.">
|
||||
<input id="enable_auto_select_input" type="checkbox" />
|
||||
<small data-i18n="Auto-select Input Text">Auto-select Input Text</small>
|
||||
</label>
|
||||
<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">
|
||||
<input id="restore_user_input" type="checkbox" />
|
||||
<small data-i18n="Restore User Input">Restore User Input</small>
|
||||
|
@ -4985,7 +4989,7 @@
|
|||
<div class="popup-crop-wrap">
|
||||
<img class="popup-crop-image" src="">
|
||||
</div>
|
||||
<textarea class="popup-input text_pole result-control" rows="1" data-result="1" data-result-event="submit"></textarea>
|
||||
<textarea class="popup-input text_pole result-control auto-select" rows="1" data-result="1" data-result-event="submit"></textarea>
|
||||
<div class="popup-inputs"></div>
|
||||
<div class="popup-controls">
|
||||
<div class="popup-button-ok menu_button result-control" data-result="1" data-i18n="Delete">Delete</div>
|
||||
|
|
|
@ -10657,6 +10657,15 @@ jQuery(async function () {
|
|||
$(document).on('click', '.open_alternate_greetings', openAlternateGreetings);
|
||||
/* $('#set_character_world').on('click', openCharacterWorldPopup); */
|
||||
|
||||
$(document).on('focus', 'input.auto-select, textarea.auto-select', function () {
|
||||
if (!power_user.enable_auto_select_input) return;
|
||||
const control = $(this)[0];
|
||||
if (control instanceof HTMLInputElement || control instanceof HTMLTextAreaElement) {
|
||||
control.select();
|
||||
console.debug('Auto-selecting content of input control', control);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).keyup(function (e) {
|
||||
if (e.key === 'Escape') {
|
||||
const isEditVisible = $('#curEditTextarea').is(':visible');
|
||||
|
|
|
@ -202,6 +202,7 @@ let power_user = {
|
|||
trim_spaces: true,
|
||||
relaxed_api_urls: false,
|
||||
world_import_dialog: true,
|
||||
enable_auto_select_input: false,
|
||||
tag_import_setting: tag_import_setting.ASK,
|
||||
disable_group_trimming: false,
|
||||
single_line: false,
|
||||
|
@ -1596,6 +1597,7 @@ async function loadPowerUserSettings(settings, data) {
|
|||
$('#single_line').prop('checked', power_user.single_line);
|
||||
$('#relaxed_api_urls').prop('checked', power_user.relaxed_api_urls);
|
||||
$('#world_import_dialog').prop('checked', power_user.world_import_dialog);
|
||||
$('#enable_auto_select_input').prop('checked', power_user.enable_auto_select_input);
|
||||
$('#trim_spaces').prop('checked', power_user.trim_spaces);
|
||||
$('#continue_on_send').prop('checked', power_user.continue_on_send);
|
||||
$('#quick_continue').prop('checked', power_user.quick_continue);
|
||||
|
@ -3773,6 +3775,12 @@ $(document).ready(() => {
|
|||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#enable_auto_select_input').on('input', function () {
|
||||
const value = !!$(this).prop('checked');
|
||||
power_user.enable_auto_select_input = value;
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#spoiler_free_mode').on('input', function () {
|
||||
power_user.spoiler_free_mode = !!$(this).prop('checked');
|
||||
switchSpoilerMode();
|
||||
|
|
Loading…
Reference in New Issue