I need to find the position of the character in the input field based on the mouse movement.
for example: if the input field has value as 'abcde' and I am moving my mouse on the character 'a' then the position will be 1, 'b' will provide 2 and so on for the other characters.
I did find few examples that works with the selectionStart etc., but they work only when the caret is placed at some position and then find the placed position.
What I am looking for is - that there may / may not be click done in the input field, regardless when the mouse is moving on the characters - I be able to know the position of the character, where mouse hovered upon.
I haven't come across any idea how I can convert the mouse coordinates respectively into character position. Are there any such javascript API's?
Any help / pointers / ideas are much appreciated.
Update
My end goal is automatically move the caret as the drag is happening over the contenteditable div. I found a following link asking for the similar problem - but there is no solution suggested so far.
caret auto move - https://stackoverflow.com/questions/12397792/update-caret-position-of-input-and-insert-text-on-drop-event/53660415#53660415
I have also added another example to show the different behavior of native drag vs. jQuery drag. I am using jQuery draggable that does not support auto drag of caret.