How to set cursor position to end of text in CKEditor?

后端 未结 8 1174
予麋鹿
予麋鹿 2020-12-01 12:34

Is there a way to set the cursor to be at the end of the contents of a CKEditor?

This developer asked too, but received no answers:

http://cksource.com/forum

相关标签:
8条回答
  • 2020-12-01 13:23

    This is the easiest solution provided by the ckeditor API. I have tested it on IE10+, ff, safari and Chrome:

    range = editor.createRange();
    // the first parameter is the last line text element of the ckeditor instance
    range.moveToPosition(new CKEDITOR.dom.node(editor.element.$.children[pos - 1]), CKEDITOR.POSITION_BEFORE_END)
    range.collapse()
    editor.getSelection().selectRanges([ range ])
    
    0 讨论(0)
  • 2020-12-01 13:26

    This will work for sure. CKEDITOR.config.startupFocus = 'end';

    0 讨论(0)
提交回复
热议问题