Open utterances-bot opened 1 year ago
You need to set the caret position and refocus after hitting tab so you can keep typing, something like
textarea.selectionStart = textarea.value.substring(0, start).length + 1;
textarea.selectionEnd = textarea.value.substring(0, start).length + 1;
textarea.focus();
would do the trick.
This works pretty cool only if no multi-line sentence is entered, if it is then, it won't work accurately
How to Quickly Add Line Numbers to HTML Textarea - Webtips
Learn how you can easily add line numbers to any HTML textarea using 10 lines of JavaScript code, a couple of DOM elements and some CSS.
https://www.webtips.dev/add-line-numbers-to-html-textarea?utterances=1e8b28120e433f45002802adzik%2Fh4nVpWrAequ0UAn2EtNrOf1ojZTyEHCqJ%2Bo4tilJ43lX5qteOfTmlghiroybD%2BQvDPeswn6QzsFtEEHn%2FhNAkLHilcCjUyLWBNjd7lX6msjbfuQyqby9IoY%3D