You are here

12 June 2015

Get cursor position in CKEditor is simple if you know some facts. You have to have the instance initiated, so simple jQuery ready would not work. You can get selection and use that functionality to get the caret position.

Source code viewer
  1. // Make sure ckeditors instance is ready.
  2. CKEDITOR.on('instanceReady', function(e) {
  4. var selection = e.editor.getSelection();
  5. var range = selection.getRanges()[0];
  6. var cursor_position = range.startOffset;
  8. });
Programming Language: Javascript