https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint
The
caretPositionFromPoint()method of theDocumentinterface returns aCaretPositionobject, containing the DOM node, along with the caret and caret's character offset within that node.
Note: it is not supported on safari.