How do you append a custom button in Summernote?

13 views Asked by At

How do you define a custom button, but append it to the list of existing buttons and not destroy the defaults?

These docs explain how to add a custom button to the Summernote toolbar. However, doing this wipes out all the default buttons.

I suspect I need to use initialize, as their docs imply, but their usage doesn't make sense.

If I try defining a custom initialize in my summernote call, and append a button there, it has no effect:

<script>

$(document).ready(function() {

    $('#id_body_template').summernote({
        initialize: function () {

          // create button
          var ui = $.summernote.ui;
          var button = ui.button({
            className: 'note-btn-bold',
            contents: '<i class="fa fa-bold">',
            click: function (e) {
              context.invoke('editor.bold'); // invoke bold method of a module named editor
            }
          });

          // generate jQuery element from button instance.
          this.$button = button.render();
          $toolbar.append(this.$button);
        }

    });

});

</script>

What am I doing wrong?

0

There are 0 answers