Yogendra Sahu

Yogendra Sahu

  • 1.2k
  • 587
  • 138.2k

ckEditors Autofocus

Mar 5 2019 5:17 AM
How do I to set cursor position in the selected ckeditor by providing id to the ckeditors list?
 
I am having 7 ckeditor in my page and a side menu containing the name/title provided to the ckeditor.I want to set the cursor/setfocus to the selected ckeditor by clicking the title/name of the ckeditor from side menu.
 
I have used the following:
 
Code 1:
 
//Giving error : scrollIntoView is not a function
var element = editor.document.getById('id');
var range;
if(element)
{
element.scrollIntoView();
range = editor.createRange();
range.moveToPosition(element, CKEDITOR.POSITION_AFTER_START);
editor.getSelection().selectRanges([range]);
}
 
Code 2:
 
onReady(event: any) //giving error : cannot read property focus of undefined
{
setTimeout(() => event.editor.focus(), 1000);
}
 
please help me out with this

Answers (2)