var range = window.getSelection().getRangeAt(0);
var preCaretRange = range.cloneRange();
preCaretRange.selectNodeContents(element);
preCaretRange.setEnd(range.endContainer, range.endOffset);
caretOffset = preCaretRange.toString().length;
caretOffset is the caret position of the content editable div, this bit of code doesn’t take into account line breaks however, something I’m hoping to make it do next, but first I need to understand what is going on here.
I search up “what is a javascript range” and I get hits for a slider like mechanism. Is getRangeAt related to this sliding element? Any advice?