Config.js django-ckeditor 中的文件未应用配置

Config.js file in django-ckeditor not applying configurations

我一直在尝试通过修改 config.js 文件来设置 Django-CKEditor 的样式,但都无济于事;我在 config.js 中的自定义配置不起作用。我已经手动修改了默认的 CSS 文件,但所有这些修改也无法正常工作。虽然当我用Chrome的developers tool做一些修改时,它们都起作用了。我的问题是,config.js 文件在 Django 中不可用吗?

config.js

CKEDITOR.editorConfig = function( config ) {
    // Define changes to default configuration here. For example:
    // config.language = 'fr';
    // config.uiColor = '#AADC6E';
    config.uiColor = '#000000';
    config.enterMode = CKEDITOR.ENTER_BR;
    config.width = "100%";
    config.height = "300";
    config.extraPlugins = 'autogrow';
    config.autoGrow_minHeight = 250;
    config.autoGrow_maxHeight = 600;
};

settings.py

CKEDITOR_UPLOAD_PATH = "images/avatar/"
CKEDITOR_IMAGE_BACKEND = 'pillow'

CKEDITOR_RESTRICT_BY_USER = True
CKEDITOR_CONFIGS = {
    'default': {
        'skin': 'moono-lisa',
        'toolbar_Basic': [
            ['Source', '-', 'Bold', 'Italic']
        ],
        'toolbar_Custom': [
            {'name': 'styles', 'items': ['Styles']},
            {'name': 'basicstyles',
             'items': ['Bold', 'Italic', 'Underline']},
            {'name': 'colors', 'items': ['TextColor']},
            {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']},
            {'name': 'insert', 'items': ['Smiley']},
        ],
        'toolbar': 'Custom',
    },
}

HTML

<script type="text/javascript" src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script>

对于可能遇到相同问题的任何人,无需修改 Django 应用中的 config.js 文件,除非您有更多高级选项可供使用。在最简单的形式中,您可以简单地在 settings.py 文件中的 CKEDITOR_CONFIGS 设置中进行修改。

在下面查看我的修改示例。

CKEDITOR_CONFIGS = {
'default': {
        'toolbar_Basic': [
            ['Source', '-', 'Bold', 'Italic']
        ],
        'width': 'auto',
        'toolbar_Custom': [
            {'name': 'basicstyles',
         ...more settings...
        ],
        'toolbar': 'Custom',

        # more custom settings
        'toolbarCanCollapse': True,
        'uiColor': '#f4f5f7',
    },
}