ruby-on-railssummernote

summernote styleTags along with toolbar


Summernote give options to custom toolbar like

$('#summernote').summernote({
  toolbar: [
    // [groupName, [list of button]]
    ['style', ['bold', 'italic', 'underline', 'clear']],
    ['font', ['strikethrough', 'superscript', 'subscript']],
    ['fontsize', ['fontsize']],
    ['color', ['color']],
    ['para', ['ul', 'ol', 'paragraph']],
    ['height', ['height']]
  ]
});

& than for setting h1, h2 etc

$(".summernote").summernote({
    styleTags: ['h1', 'h2']
});

But how to use the both in single method like ?

$('#summernote').summernote({
  styleTags: ['h1', 'h2'],
  toolbar: [
    // [groupName, [list of button]]
    ['style', ['bold', 'italic', 'underline', 'clear']],
    ['font', ['strikethrough', 'superscript', 'subscript']],
    ['fontsize', ['fontsize']],
    ['color', ['color']],
    ['para', ['ul', 'ol', 'paragraph']],
    ['height', ['height']]
  ]
});

I have tried multipe variations but not working


Solution

  • You should add 'style' button to your btns group.

    Try code below.

    $('#summernote').summernote({
        toolbar: [
             ['style', ['bold', 'italic', 'underline']],
             ['para', ['ul', 'ol', 'paragraph', 'style']],
        ],
        styleTags: ['p', 'h4'],
    });