Dan Kaufman
Dan Kaufman

Reputation: 115

Summernote default font being over-written by Bootswatch theme

I'm using Summernote with the Bootswatch theme 'Yeti', which uses Open Sans as it's font. When the editor initializes it sets the default font to 'Open Sans' even though that is not in my list of fonts:

fontNames: ['Arial', 'Arial Black', 'Courier New', 'Helvetica', 'Helvetica Neue', 'Impact', 'Lucide Grande', 'Tahoma', 'Times New Roman', 'Verdana'],

If you change the font to something else- say, Arial- then Open Sans disappears from the font dropdown. We're using Open Sans on the page that displays the Summernote editor but the code being generated by Summernote will be displayed on a page where Open Sans is not being loaded. For consistency and display-ability's sake we need the generated code to ONLY use fonts that are universal (such as Arial, Helvetica, etc...).

I need the default font to be 'Arial' but, as of Summernote 0.7.0, defaultFontName is nonexistent. I also tried manually triggering a click of the Arial button but to no avail:

onInit: function() {
            $("div.note-btn-group.btn-group.note-fontname > div > div > li:nth-child(1) > a").trigger('click');    
        }

Upvotes: 1

Views: 1964

Answers (1)

Lovethenakedgun
Lovethenakedgun

Reputation: 855

There is an option in summernote called addDefaultFonts which adds any default fonts available on the page it renders on into the editor.

Still not sure how it's actually grabbing them, but this can be set to false in the summernote init, e.g. $("#editor").summernote({addDefaultFonts: false}).

Should make it so that "Open Sans" won't show up unless you explicitly specify it in the fontNames array parameter in the same init.

Upvotes: 1

Related Questions