无法自定义DjangocketEditor工具B

2024-04-26 11:24:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试自定义django-ckeditor工具栏。在

我的模型字段是:

answer = RichTextField(
    verbose_name    = "Answer presented to user",
    config_name     = 'answer_ckeditor',
    )

设置.py我有

^{pr2}$

我的HTML是:

<textarea id="answer_1" name="answer_1" required class="form-control quiz-search-box" placeholder="Option 1"></textarea>
<script>
    CKEDITOR.replace( 'answer_1' );
</script>

我只需要标准的编辑菜单。我尝试过使用default并从字段定义中删除config\u名称,但没有区别。在

我需要在JavaScript CKEDITOR.replace( 'answer_1' );中做一些不同的事情来让它拿起我的工具栏吗?在


Tags: djangoanswername模型configckeditorverbosescript
2条回答

{你试过了吗?在

CKEDITOR_CONFIGS = {
    'answer_ckeditor': {
        'skin': 'moono',
        #'skin': 'office2013',
        'toolbar': 'Custom',
        'toolbar_Custom': [
            ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'],
            ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-',
                       'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl',
                       'Language'],
            ['Styles', 'Format', 'Font', 'FontSize'],
            ['TextColor', 'BGColor']
        ]
    }
}

这是我的解决方案。在

我把CKEDITOR.replace( 'answer_1' );改为CKEDITOR.replace( 'answer_1', {customConfig: "{% static 'js/custom/config.js' %}"});

在配置文件文件看起来像:

CKEDITOR.editorConfig = function( config ) {
    config.toolbarGroups = [
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
        { name: 'styles', groups: [ 'styles' ] },
        { name: 'colors', groups: [ 'colors' ] },
    ];

    config.removeButtons = 'Underline,Subscript,Superscript,Cut,Undo,Scayt,Link,Image,Maximize,Source,About';
};

我很满意。在

相关问题 更多 >