我的源代码:
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
我会得到这个错误: Uncaught TypeError: Cannot read property 'type' of null
在某些 ckeditor.js 文件中
知道如何在 newElement 之后获取光标位置吗?
解决方案是一个小true
var bookmark2 = oEditor.getSelection().createBookmarks2(true); // second bookmark