我访问了http://summernote.org/examples/#codemirror-as-codeview,但我还是无法让codemirror工作。我从所有的codemirror css和javascript中得到200个响应,但是当我按下代码视图时,我仍然是空白的。这是我的SUMMER_NOTE配置。
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 :(得分:0)
我发现js
之后加载了default_js
,所以你必须在summernote.min.js
之前加载所有的codemirror脚本。这里<head>
内的<iframe>
标记加载了这两个文件,我添加了评论。
<!-- 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_url
is defined locally。