2016-11-25 1 views
0

툴바 django-ckeditor을 사용자 정의하려고합니다.django-ckeditor 툴바를 사용자 정의 할 수 없습니다.

모델 필드입니다 : 내가 가진

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

settings.py

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

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> 

표준 ckeditor 메뉴를 얻었습니다. 나는 디폴트를 사용하고 필드 정의에서 config_name을 제거하려고 시도했지만 차이는 없다.

내 도구 모음을 가져 오려면 JavaScript CKEDITOR.replace('answer_1');에서 뭔가 다른 점이 있습니까?

답변

0

여기 내 해결책이 있습니다. 그것은 너무 일하고있어 내가 만족 스럽습니다

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

:

나는 것처럼 config.js 파일이 보이는 CKEDITOR.replace('answer_1', {customConfig: "{% static 'js/custom/config.js' %}"});

CKEDITOR.replace('answer_1');을 변경했습니다.

0

documentation처럼 해 보셨습니까?

+0

예, 시도했지만 작동하지 않았습니다. 내 솔루션이 주어진다. – HenryM