2016-12-16 16 views
0

私はhttp://summernote.org/examples/#codemirror-as-codeviewを訪問しましたが、まだ動作するようにcodemirrorを取得できません。私はすべてのcodemirror CSSとjavascriptから200の回答を得ていますが、コードビューを押すとまだ空白になります。ここに私のSUMMER_NOTE設定があります。django-summernoteヘルプコードミラーを追加する

SUMMERNOTE_CONFIG = { 
    'toolbar': [ 
     ['cmds', ['undo', 'redo', 'clear']], 
     ['style', ['style']], 
     ['font', ['bold', 'italic', 'underline', 'strikethrough']], 
     ['font2', ['superscript', 'subscript']], 
     ['color', ['color']], 
     ['para', ['ul','ol']], 
     ['layout', ['hr', 'table']], 
     ['insert', ['link', 'picture']], 
     ['misc', ['codeview']], 
    ], 
    'width': '100%', 
    'css': (
     '//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.css', 
     '//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/theme/monokai.css', 
    ), 
    'js': (
     '//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.js', 
     '//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/mode/xml/xml.js', 
     '//cdnjs.cloudflare.com/ajax/libs/codemirror/2.36.0/formatting.js', 
    ), 
    'codemirror': { 
     'theme': 'monokai', 
    } 
} 

これは正しい設定方法ですか?

答えて

0

jsdefault_jsの後に読み込まれていることがわかりましたので、すべてのcodemirrorスクリプトをsummernote.min.jsの前に読み込む必要があります。ここではの中に<head>というタグがあり、両方の方法でそれらのファイルを読み込んでいます。コメントを追加しました。

<!-- Loaded via js and css (doesn't work) --> 
<head> 
    <title>django-summernote frame</title> 
    <!-- From default_css --> 
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"> 
    <link href="/static/django_summernote/summernote.css" rel="stylesheet"> 
    <link href="/static/django_summernote/django_summernote.css" rel="stylesheet"> 
    <!-- End default_css --> 
    <!-- From css --> 
    <link href="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.css" rel="stylesheet"> 
    <link href="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/theme/monokai.css" rel="stylesheet"> 
    <!-- end css --> 
    <!-- From default_js --> 
    <script src="//code.jquery.com/jquery-1.9.1.min.js"></script> 
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> 
    <script src="/static/django_summernote/jquery.ui.widget.js"></script> 
    <script src="/static/django_summernote/jquery.iframe-transport.js"></script> 
    <script src="/static/django_summernote/jquery.fileupload.js"></script> 
    <script src="/static/django_summernote/summernote.min.js"></script> 
    <!-- end default_js --> 
    <!-- From js --> 
    <script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.js"></script> 
    <script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/mode/xml/xml.js"></script> 
    <script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/2.36.0/formatting.js"></script> 
    <!-- end js --> 
</head> 

<!-- Loaded via default_js and default_css (works) --> 
<head> 
    <title>django-summernote frame</title> 
    <!-- From default_css --> 
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"> 
    <link href="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.css" rel="stylesheet"> 
    <link href="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/theme/monokai.css" rel="stylesheet"> 
    <link href="/static/django_summernote/summernote.css" rel="stylesheet"> 
    <link href="/static/django_summernote/django_summernote.css" rel="stylesheet"> 
    <!-- end default_css --> 
    <!-- From default_js --> 
    <script src="//code.jquery.com/jquery-1.9.1.min.js"></script> 
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> 
    <script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.js"></script> 
    <script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/mode/xml/xml.js"></script> 
    <script src="//cdnjs.cloudflare.com/ajax/libs/codemirror/2.36.0/formatting.js"></script> 
    <script src="/static/django_summernote/jquery.ui.widget.js"></script> 
    <script src="/static/django_summernote/jquery.iframe-transport.js"></script> 
    <script src="/static/django_summernote/jquery.fileupload.js"></script> 
    <script src="/static/django_summernote/summernote.min.js"></script> 
    <!-- end default_js --> 
</head> 

だから私はそれが私のSUMMERNOTE_CONFIGように構成することにより動作させることができました:

SUMMERNOTE_CONFIG = { 
    'toolbar': [ 
     ['cmds', ['undo', 'redo', 'clear']], 
     ['style', ['style']], 
     ['font', ['bold', 'italic', 'underline', 'strikethrough']], 
     ['font2', ['superscript', 'subscript']], 
     ['color', ['color']], 
     ['para', ['ul','ol']], 
     ['layout', ['hr', 'table']], 
     ['insert', ['link', 'picture']], 
     ['misc', ['codeview']], 
    ], 
    'width': '100%', 
    'css': (
     '//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.css', 
     '//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/theme/monokai.css', 
    ), 
    'default_js': (
     '//code.jquery.com/jquery-1.9.1.min.js', 
     '//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js', 
     '//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/codemirror.js', 
     '//cdnjs.cloudflare.com/ajax/libs/codemirror/3.20.0/mode/xml/xml.js', 
     '//cdnjs.cloudflare.com/ajax/libs/codemirror/2.36.0/formatting.js', 
     static_url('django_summernote/jquery.ui.widget.js'), 
     static_url('django_summernote/jquery.iframe-transport.js'), 
     static_url('django_summernote/jquery.fileupload.js'), 
     static_url('django_summernote/summernote.min.js'), 
    ), 
    'codemirror': { 
     'theme': 'monokai', 
    } 
} 

P.S.をstatic_urlis defined locally