I am trying to get the CKEditor plugin, codesnippet, to work in the django admin but am unable to. CKEditor works if I don\'t define any CKEDIT_CONFIGS in my settings.py. It
The Code Snippet plugin has various dependencies each of which has sub-dependencies, i.e.:
I had to as a minimum add Code Snippet, Widget and Line Utils in the ckeditor/plugins path to get it to work, as well as use the following setting to get the button to show up in the toolbar.
CKEDITOR_CONFIGS = {
'default': {
'toolbar':[ ['CodeSnippet', ], ],
'height': 400,
'width': 900,
'removePlugins': 'stylesheetparser',
'extraPlugins': 'codesnippet',
},
}
So once all your plugin dependencies are all installed it should work.
I've been battling the same problem for days and I guess I found a workaround for this problem.
As you have noticed too, it tries to read this "static/ckeditor/ckeditor/plugins/codesnippet/plugin.js" javascript but it cannot locate it, even if you've put the plugin in the folder of "YOUR_PROJECT_DIR/static/ckeditor/ckeditor/plugins". The reason is, django-ckeditor is not searching the static directory in your project directory, it is searching it own static directory in its own path in site-packages. As a result, you may do the following as a workaround.
P.S.:
The actual cause is that plugin.js is not added by the CKEditor builder. I have no idea why that is, but each plugin's repository does have a plugin.js.
I fought with this for ages trying to install the plugins and dependencies manually.
In the end, I packaged up all the plugins I wanted with CKEditor Builder and dropped it into a ckeditor directory in my STATICFILES_DIRS. /static/ckeditor/ckeditor/plugins & .js etc
I am using CKEditor within https://github.com/django-blog-zinnia/zinnia-wysiwyg-ckeditor so my settings look like.....
CKEDITOR_UPLOAD_PATH = 'uploads'
CKEDITOR_IMAGE_BACKEND = 'pillow'
CKEDITOR_CONFIGS = {
'zinnia-content': {
'toolbar': 'Zinnia',
"extraPlugins":'codesnippet',
"codeSnippet_theme": "monokai_sublime",
'skin': 'moono-dark',
'toolbar_Zinnia': [
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
['Undo', 'Redo'],
['Scayt'],
['Link', 'Unlink', 'Anchor'],
['Image', 'Table', 'HorizontalRule', 'SpecialChar'],
['Source'],
['Maximize', 'Resize'],
'/',
['Bold', 'Italic', 'Underline', 'Strike',
'Subscript', 'Superscript', '-', 'RemoveFormat'],
['NumberedList', 'BulletedList', '-',
'Outdent', 'Indent', '-', 'Blockquote'],
['Styles', 'Format'],['CodeSnippet'],
'/',
['Smiley', 'About', 'Preview', 'Templates' ],
],
},
}
So hopefully, without Zinnia, your settings would look like....
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'Full',
"extraPlugins":'codesnippet',
"codeSnippet_theme": "monokai_sublime",
'skin': 'moono-dark',
},
}
This is a probably a different cause of the problem than what was original asked about, because it was a few years ago. But a lot of plugins are not working with the latest release of django-ckeditor, version 5.1.0.
Took me ages to work out what was wrong - and it's just that the latest version does not include all the plugins. If you pip uninstall and the install version 5.0.0, you get the full plugin suite.
Figure this might help someone who finds this thread.