Can't get CKEditor plugins to work in django

前端 未结 5 1827
后悔当初
后悔当初 2021-01-07 02:37

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

5条回答
  •  旧巷少年郎
    2021-01-07 03:29

    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',                 
            },
        }
    

提交回复
热议问题