不允许在CKEditor中使用特殊字符
可以在CKEditor中禁用某些特殊字符,如♦ (不允许在CKEditor中使用特殊字符,ckeditor,Ckeditor,可以在CKEditor中禁用某些特殊字符,如♦ (♦)或•(•)? 因此,用户应该根本无法插入它们。最后,我为此创建了一个自定义插件,希望能对其他人有所帮助 })) 及 CKEDITOR.replace('Description'{ 自定义值:{CKEditorLegalCharacters:“\u0020-\u02AF\”} }); CKEDITOR.plugins.add('customcontentfilter', { afterInit: function (e
♦
)或•(•
)?因此,用户应该根本无法插入它们。最后,我为此创建了一个自定义插件,希望能对其他人有所帮助 })) 及
CKEDITOR.replace('Description'{
自定义值:{CKEditorLegalCharacters:“\u0020-\u02AF\”}
});
CKEDITOR.plugins.add('customcontentfilter', {
afterInit: function (editor) {
var dataProcessor = editor.dataProcessor,
dataFilter = dataProcessor && dataProcessor.dataFilter,
htmlFilter = dataProcessor && dataProcessor.htmlFilter,
legalCharacters = editor.config.customValues && editor.config.customValues.CKEditorLegalCharacters,
illegalCharactersRegex = new RegExp("[^" + legalCharacters + "]", "g");
if (dataFilter) {
dataFilter.addRules({
text: function (text) {
return text.replace(illegalCharactersRegex, '');
}
});
}
if (htmlFilter) {
htmlFilter.addRules({
text: function (text) {
return text.replace(illegalCharactersRegex, '');
}
});
}
}