diff --git a/public/index.html b/public/index.html index 689b233ec..39d25427a 100644 --- a/public/index.html +++ b/public/index.html @@ -4098,6 +4098,10 @@ Lorebook Import Dialog + + + Auto-select Input Text + Restore User Input @@ -4985,7 +4989,7 @@ - + Delete diff --git a/public/script.js b/public/script.js index 089738e83..daea9cc50 100644 --- a/public/script.js +++ b/public/script.js @@ -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'); diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index c50cf7ae3..a10033eda 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -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();