JSFiddle - React, Tailwind, and code Playground
HTML
<html>
<head>
<script>
function fEdit(elem, e) {
elem.contentEditable = "true";
var range;
if (document.selection) {
range = window.document.selection.createRange();
range.collapse();
range.select();
} else {
range = window.getSelection();
if (range.rangeCount > 0) range.collapseToStart();
}
setTimeout(function() { elem.focus(); }, 10);
//elem.focus();
};
</script>
</head>
<body>
<div id="mydiv" class="cmydiv" ondblclick="fEdit(this, event)">haha brouhaha beeee lololol</div>
</body>
</html>
CSS
.cmydiv {
width: 100px;
height: 100px;
border: 1px solid #000000;
cursor: default;
}