CKEditor: set cursor/caret positon

后端 未结 2 1932
囚心锁ツ
囚心锁ツ 2021-01-21 00:08

How can I position the caret in CKEditor3.x? I have 2 positions and I want use insertHTML() on both positions.

Pseudo-code:

editor.setCaret(20); // funct         


        
2条回答
  •  遇见更好的自我
    2021-01-21 00:33

    If you use insertElement instead of insert html (and say, insert a span element) the following should probably work:

    editor.insertElement(element);
    var range = new CKEDITOR.dom.range(editor.document);
    range.moveToElementEditablePosition(element, true);
    editor.getSelection().selectRanges([range]);
    

提交回复
热议问题