Insert hard linebreaks into textareas with vanilla JavaScript

Jun 30, 2016

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.