Insert hard linebreaks into textareas with vanilla JavaScript
While working on my little checklist app
I needed a way to hard-wrap text entered into a <textarea>
and preserve the
linebreaks when copy-pasting it somewhere else. HTML and CSS don’t support this,
so I wrote some vanille JavaScript code to insert the linebreaks, trying to
break on words whenever possible.