Utility css class to auto-select input/textarea - Add an event listener on document level that checks for focus events on input/textarea controls. If they have the class "auto-select" the content will be auto-selected

97096add2a5f9309e32b923ee08489e6b1a366d6

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +8 -0Showing whitespace changes
public/script.js+8 -0
@@ -10647,6 +10647,14 @@ jQuery(async function () {
1064710647 $(document).on('click', '.open_alternate_greetings', openAlternateGreetings);
1064810648 /* $('#set_character_world').on('click', openCharacterWorldPopup); */
1064910649
10650+ $(document).on('focus', 'input.auto-select, textarea.auto-select', function () {
10651+ const control = $(this)[0];
10652+ if (control instanceof HTMLInputElement || control instanceof HTMLTextAreaElement) {
10653+ control.select();
10654+ console.debug('Auto-selecting content of input control', control);
10655+ }
10656+ });
10657+
1065010658 $(document).keyup(function (e) {
1065110659 if (e.key === 'Escape') {
1065210660 const isEditVisible = $('#curEditTextarea').is(':visible');