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:
xxxxxxxxxx
1
var EDITOR_CONFIG = {
2
// ...
3
on: {
4
pluginsLoaded: function(evt) {
5
evt.editor.dataProcessor.dataFilter.addRules({
6
comment: function() {
7
return false;
8
}
9
});
10
}
11
}
12
13
// ...
14
};
Example configuration:
xxxxxxxxxx
1
var config = {
2
language: 'en',
3
toolbar: [
4
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Underline'] },
5
{ name: 'paragraph', items: ['NumberedList', 'BulletedList'] },
6
{ name: 'links', items: ['Link', 'Unlink'] },
7
{ name: 'clipboard', items: ['PasteText', '-', 'Undo', 'Redo'] },
8
{ name: 'document', items: [ 'Source' ] }
9
],
10
on: {
11
pluginsLoaded: function(evt) {
12
evt.editor.dataProcessor.dataFilter.addRules({
13
comment: function() {
14
return false;
15
}
16
});
17
}
18
},
19
format_tags: 'h1;h2;p',
20
extraPlugins: 'autogrow,codesnippet,emoji',
21
autoGrow_onStartup: true,
22
autoGrow_minHeight: 120,
23
codeSnippet_theme: 'googlecode', //'tomorrow',
24
removeDialogTabs: 'link:advanced'
25
};
26
27
var input = document.querySelector('#editor-input');
28
var editor = CKEDITOR.replace(input , config);
0 commentsShow commentsAdd comment