2017-07-06 569 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; }' –