javascriptjqueryckeditorckeditor4.x

retain CKEditor scroll bar at cursor position


I'm using the similar code to retain cursor position for ckeditor.

var range = null;
editor.on( 'blur', function() {
    range = editor.getSelection().getRanges()[ 0 ];
});
someElement.on('click',function() {
var editor = CKEDITOR.instances.editor1;
 if(editor){
    editor.focus();
    range.select();  
 }
});

I'm able to retain cursor position but the scrollbar scrolls to the top. How can i keep/retain the scrollbar at same position as of cursor's?


Solution

  • range.select().scrollIntoView() helped me out!!