我有一个CKEditor.I无疑要检查最后在的CKEditor:检查是否删除的最后一个元素是“BR”中的CKEditor
删除的元素CKEditor的是BR tag.How我可以检查在CKEditor
而我正在尝试下面的方式来做到这一点。
CKEDITOR.replace('editor', {
allowedContent: true,
toolbarGroups: [
{ name: 'mode' },
{ name: 'basicstyles' }
],
on: {
contentDom: function() {
var editor = this;
this.editable().attachListener(editor, 'key', function(evt) {
// If not backspace or delete.
if ((evt.data.keyCode in { 8: 1, 46: 1 })) {
// Get selected element.
var lastElement = editor.elementPath().lastElement,
parent = lastElement.getParent();
console.log(lastElement,parent);
console.log(lastElement.$);
document.getElementById("sr").innerHTML = lastElement.$.getAttribute("src")
}
});
}
}
});
好的,但它没有给出删除的“br”位置。 –
我只在用户点击退格或删除按钮时才触发此事件。 –