February 24, 2013
Tinymce – Is it possible to get caret position of textarea corresponding to WYSIWYG Editor?
Question by user1643156
I’m wondering if we can get the real caret position of textarea when the fake cursor is in certain position under WYSIWYG Editor?
To better understand the question, please see the image below
Under WYSIWYG mode, when the cursor is after s, we get position 53. and when the cursor is after t, we get position 79.
The code would be something like…
function getRealCaretPosition() {
// all the dirty work goes here
}
// Ctrl + Q
if(e.ctrlKey && e.which == 81) {
var pos = getRealCaretPosition();
alert(pos);
}
Is this possible to be achieved, in theory?