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

后端 未结 8 1333
予麋鹿
予麋鹿 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:21

    According to the documentation for CKEditor 4, you can do the following once you have the editor object.

    var range = editor.createRange();
    range.moveToPosition( range.root, CKEDITOR.POSITION_BEFORE_END );
    editor.getSelection().selectRanges( [ range ] );
    

    Link: http://docs.ckeditor.com/#!/api/CKEDITOR.dom.selection (under selectRanges function).

提交回复
热议问题