Get the offset of a character by wrapping it in a textNode.
https://lab.miguelmota.com/textnode-offset
npm install textnode-offset
bower install textnode-offset
<div id="text">Programs must be written for people to read, and only incidentally for machines to execute.</div>
var parentElement = document.getElementById('text');
var index = 20;
var offset = textNodeOffset(parentElement, index);
console.log(offset);
//
{
"left": 148.875,
"top": 110.875
}
MIT