Open alessandrofrancesconi opened 9 years ago
+1, I would really like to know this as well. My current implementation only gets me this far:
I can identify my currently focussed textbox with Window.selection:
var selection = window.getSelection();
I can identify the caret position with Selection.focusOffset:
var focus = selection.focusOffset;
However, this counter only counts characters on the current line. So if I'm 2 characters in on line 3 focus
will be 2. This dosn't tell me anything about how many characters I am into the entire text.
Just a clarification: I'm talking about position based on pixels, not characters/lines.
Hello, I see that the editor uses Rangy to work with selection and so on. Assuming this... is it possible to have a public method that returns the current (relative or absolute) position of the caret inside the editable area?
Something like
editor.getCaretPosition() => { left; top }