The caretPositionFromPoint() method of the Document interface returns a CaretPosition object, containing the DOM node, along with the caret and caret's character offset within that node.
caretPositionFromPoint()
MDN Reference
Optional
The
caretPositionFromPoint()method of the Document interface returns a CaretPosition object, containing the DOM node, along with the caret and caret's character offset within that node.MDN Reference