是否可以在CKEditor中禁用一些特殊字符,如♦(♦
)或•(•
)?
因此用户不应该完全插入它们
答案 0 :(得分:0)
最后我为此创建了一个自定义插件,希望对某人有所帮助
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, '');
}
});
}
}
});
和
CKEDITOR.replace('Description', {
customValues: { CKEditorLegalCharacters: "\u0020-\u02AF\" }
});