- 首先在https://ckeditor.com/cke4/addon/codesnippet定制下载codesnippet这个包。
- 将下载的codesnippet文件夹解压放置于ckeditor(关于ckeditor相关内容,请参考添加富文本编辑器ckeditor)的plugins目录下(如果存在则替换)。
- 配置ckeditor中的config.js。
CKEDITOR.editorConfig = function( config ) {
config.extraPlugins: "codesnippet";
codeSnippet_theme: "zenburn";
};
- 配置settings.py文件。
CKEDITOR_CONFIGS = {
'comment_ckeditor': {
'toolbar': 'custom',
'toolbar_custom': [
['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript'],
["TextColor", "BGColor", 'RemoveFormat'],
['NumberedList', 'BulletedList'],
['Link', 'Unlink'],
["Smiley", "SpecialChar", 'Blockquote'],
],
'extraPlugins': 'codesnippet',
'width': 'auto',
'height': '180',
'tabSpaces': 4,
'removePlugins': 'elementspath',
'resize_enabled': False,
},
'default': {
'toolbar': 'full',
'height': 300,
'width': 'auto',
'extraPlugins': 'codesnippet',
},
}
- 服务器重启即可。