insertElement之后的ckeditor中的createBookmarks2

时间:2013-10-12 12:06:39

标签: javascript ckeditor getselection

我的源代码:

var oEditor = CKEDITOR.instances.wiki__text;
var bookmark =     oEditor.getSelection().createBookmarks2(); // first bookmark
var html = '<'+b+' id="id_'+AInc+'">'+AInc+'</'+b+'>';
var newElement = CKEDITOR.dom.element.createFromHtml( html, oEditor.document );
oEditor.insertElement( newElement );
var bookmark2 = oEditor.getSelection().createBookmarks2(); // second bookmark
console.log('bm: ',bookmarks);
oEditor.getSelection().selectBookmarks( bookmark );

如果我使用first bookmark,光标会跳转到newElement之前的位置,但我希望在newElement之后有位置。但如果我使用second bookmark,我会收到此错误: 某些ckeditor.js文件中的Uncaught TypeError: Cannot read property 'type' of null

知道如何在newElement之后获取光标位置吗?

1 个答案:

答案 0 :(得分:1)

解决方案是一个小true

var bookmark2 = oEditor.getSelection().createBookmarks2(true); // second bookmark