CKEditor keystroke interception
3 answers
I solved it in a slightly different way. Instead of inserting a fixed width range, I wanted the tabs to line up across all lines. So I insert a tab character (& # 0 9) with pre formatting. I also had difficulties with insertHtml () and had to use a combination of createFromHtml () and insertElement ().
Here's my solution:
// my editor id is 'summary'
CKEDITOR.replace('summary', { ... });
var editor = CKEDITOR.instances.summary;
editor.on('key', function(ev) {
if (ev.data.keyCode == 9) { // TAB
var tabHtml = '<span style="white-space:pre">	</span>';
var tabElement = CKEDITOR.dom.element.createFromHtml(tabHtml, editor.document);
editor.insertElement(tabElement);
ev.cancel();
}
});
0
a source to share