【发布时间】:2018-07-04 04:24:32
【问题描述】:
我在 Summernote 上使用 codemirror。
我希望默认视图是 codeview。
于是我在stackoverflow和google上搜索,找到了一些方法。
首先,
$(".summernote").summernote({
callbacks:{
onInit: function(){
$("div.note-editor button[data-event='codeview']").click();
}
},height: 300,
width: '100%',
minHeight: null,
maxHeight: null,
focus: true,
placeholder: 'please, write text here!',
lang: 'ko-KR',
codemirror: { // codemirror options
theme: 'blackboard',
lineNumbers: true
}
)};
但是,这种方式行不通..
我的summernote - codeview 按钮没有 [data-event='codeview'] 标签。 按钮有 class="note-btn btn btn-default btn-sm btn-codeview"。
秒,
$('.summernote').on('summernote.init', function () {
$('.summernote').summernote('codeview.activate');
}).summernote({
height: 300,
width: '100%',
minHeight: null,
maxHeight: null,
focus: true,
placeholder: 'please, write text here!',
lang: 'ko-KR',
codemirror: { // codemirror options
theme: 'blackboard',
lineNumbers: true
}
});
也不行。
不不不,这个动作不是想要的动作。
执行此操作时,会创建两个空格。上下。
因此,我使用的是 '$(".Summernote").Summernote("code",html code);'我希望默认视图是代码视图。
【问题讨论】:
标签: codemirror summernote