JSFiddle - React, Tailwind, and code Playground

by Darby Rathbone

HTML

<div contenteditable='true'></div>
<canvas></canvas>

CSS

div {
    width:100%;
    height:1em;
    outline:black 1px solid;
}

JavaScript

//select on mouse move
/*document.addEventListener('mousemove',function(e){window.getSelection().selectAllChildren(e.target.parentElement);});
 */
document.addEventListener('input', function (e) {
    window.getSelection().selectAllChildren(getSelection().baseNode.parentElement);
});