【问题标题】:summernote editor - how to set codemirror default view?Summernote 编辑器 - 如何设置 codemirror 默认视图?
【发布时间】: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


    【解决方案1】:
    $('.summernote').summernote({
        callbacks: {
            onInit: function() {
                $('.summernote').summernote('codeview.activate');
            }
        }
    });
    

    为我工作

    【讨论】:

      猜你喜欢
      • 2018-02-16
      • 1970-01-01
      • 2019-06-30
      • 1970-01-01
      • 1970-01-01
      • 2016-01-28
      • 2015-01-14
      • 1970-01-01
      • 2012-01-12
      相关资源
      最近更新 更多