【问题标题】:Is There a Way To Limit The Available Paragraph Styles in Summernote?有没有办法限制 Summernote 中可用的段落样式?
【发布时间】:2016-06-06 21:01:47
【问题描述】:

我正在使用 Summernote 在基本 CMS 中进行编辑。这是我正在使用的代码:

$(document).ready(function() {

        $("#summernote").summernote({
            height: 600,
                styleWithSpan: false,
                toolbar: [
                    ['style', ['bold', 'italic', 'underline']],
                    ['para', ['ul', 'ol', 'paragraph','style']],
                    ['view', ['codeview']],
                    ['insert', ['mypicture','link','table','hr']]
                        ],
                        buttons: {
                            mypicture: PictureButton
                          },
                          disableDragAndDrop: true
                });

                $('#save').click(function(){
                    var mysave = $('#summernote').summernote('code');
                    $('#content').val(mysave);
                });
    });

在工具栏中,我使用['para',['style']] 允许用户选择标题/段落样式,例如H1P
有没有办法将下拉菜单限制为只允许他们使用 H1H2P

【问题讨论】:

    标签: javascript summernote


    【解决方案1】:

    您可以通过这种方式更改代码轻松实现它

    $(document).ready(function() {
    
            $("#summernote").summernote({
                height: 600,
                    styleWithSpan: false,
                    toolbar: [
                          ['style', ['bold', 'italic', 'underline']],
                          ['para', ['ul', 'ol', 'paragraph','style']],
                        ['view', ['codeview']],
                        ['insert', ['mypicture','link','table','hr']]
                    ],
                    styleTags: ['p', 'h1', 'h2'],
                    buttons: {
                        mypicture: PictureButton
                    },
                    disableDragAndDrop: true
    
                    });
    
                    $('#save').click(function(){
                        var mysave = $('#summernote').summernote('code');
                        $('#content').val(mysave);
                    });
        });
    

    相关行是styleTags: ['p', 'h1', 'h2']

    【讨论】:

      猜你喜欢
      • 2018-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-15
      • 1970-01-01
      相关资源
      最近更新 更多