I'm writing a program where I need the position of the cursor in an editable div, and tags should be counted as well.
Example:
<div contenteditable="true">
<p>Text here!</p>
</div>
If the cursor is placed after "Text", the cursor position should be 7, not 4. This happens when the HTML tag is included.
Solutions like this one: https://stackoverflow.com/a/53128599/12834165, only count the visible characters, resulting in the output being 4.