2017-07-06 570 views
1

我正在使用最新版本的summernote库。我如何设置默认字体大小和字体? 我想这样的,但它不工作:Summernote设置默认字体大小和字体

$('.text-editor').summernote({ 
     toolbar: [ 
      ['style', ['style']], 
      ['font', ['bold', 'italic', 'underline', 'superscript', 'subscript', 'strikethrough', 'clear']], 
      ['fontname', ['fontname']], 
      ['fontsize', ['fontsize']], 
      ['color', ['color']], 
      ['para', ['ul', 'ol', 'paragraph']], 
      ['height', ['height']], 
      ['table', ['table']], 
      ['insert', ['link', 'picture', 'video', 'hr']], 
      ['view', ['codeview']] 
     ], 
     fontsize: '16' 
    }); 

https://jsfiddle.net/dtgr5q29/142/

+0

尝试使用'fontSize:16'和'fontName:'Arial'' – yuriy636

+0

@ yuriy636仍然无法正常工作。 https://jsfiddle.net/dtgr5q29/142/ –

回答

1

一个可能的解决方案是直接使用jQuery

$('.active-textcontainer').summernote({ 
    toolbar: [ 
     ['style', ['bold', 'italic', 'underline']], 
     ['fontsize', ['fontsize']], 
     ['color', ['color']], 
     ['para', ['ul', 'ol', 'paragraph']] 
    ], 
    height:150 
}); 

$('.note-editable').css('font-size','18px'); 
字体大小样式应用到编辑DIV

更多.. How to set font-size in summernote?

感谢

+0

哦..我找到了原因。但是一点小事。它仅在我点击编辑器字段时更改字体大小。也许你知道解决这个问题的方法? –

+1

好吧,我找到了解决这个问题的方法。所以只需要像这样添加到.css文件: '.note-editable {font-family:Calibri; font-size:16px!important; }' –