2016-11-25 15 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.replace('answer_1');

CKEDITOR.replace('answer_1', {customConfig: "{% static 'js/custom/config.js' %}"});にある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'; 
}; 

0

documentationのように試しましたか?

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'] 
     ] 
    } 
} 
+0

はい、これを試しても機能しませんでした。私の解決策は与えられています – HenryM

関連する問題