EN
CK Editor 4 doesn't remove HTML comments from body
1
answers
8
points
Last time I have decided to install CK Editor 4. Everything was great until codesnippet plugin was installed and I started pasting text from system clipboard. I have noticed the content read from editor with JavaScript API contains HTML comments (<!-- -->
). They are not removed by editor what messes codesnippet and It doesn't work correct way.
I do not see any option to filter or disable comments in CK Editor.
There is some way how to fix it?
1 answer
1
points
Add rule to data filter:
var EDITOR_CONFIG = {
// ...
on: {
pluginsLoaded: function(evt) {
evt.editor.dataProcessor.dataFilter.addRules({
comment: function() {
return false;
}
});
}
}
// ...
};
Example configuration:
var config = {
language: 'en',
toolbar: [
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Underline'] },
{ name: 'paragraph', items: ['NumberedList', 'BulletedList'] },
{ name: 'links', items: ['Link', 'Unlink'] },
{ name: 'clipboard', items: ['PasteText', '-', 'Undo', 'Redo'] },
{ name: 'document', items: [ 'Source' ] }
],
on: {
pluginsLoaded: function(evt) {
evt.editor.dataProcessor.dataFilter.addRules({
comment: function() {
return false;
}
});
}
},
format_tags: 'h1;h2;p',
extraPlugins: 'autogrow,codesnippet,emoji',
autoGrow_onStartup: true,
autoGrow_minHeight: 120,
codeSnippet_theme: 'googlecode', //'tomorrow',
removeDialogTabs: 'link:advanced'
};
var input = document.querySelector('#editor-input');
var editor = CKEDITOR.replace(input , config);
0 comments
Add comment