簡體   English   中英

如何在summernote中設置font-size?

[英]How to set font-size in summernote?

我一直使用summernote作為我的默認文本編輯器,但是在初始化時我默認無法設置特定的字體大小。

到目前為止我試過了

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

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

螞蟻幫助將不勝感激。

我從來沒有使用過summernote ,但是看看API ,沒有任何東西(至少現在)指定默認字體大小,我做了一些像你一樣嘗試的測試,似乎沒有人工作。

一個可能的解決方案是使用jQuery直接將font-size樣式應用於編輯器div因為當您在對象中初始化summernote ,始終創建以下div<div class="note-editable" ...>...</div> 因此,您可以在初始化后執行以下操作$('.note-editable').css('font-size','18px'); 在你的代碼中,這可能是:

$('.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編輯器的class名在下一個版本上發生變化,這將無法工作,但是這對你的情況來說已經足夠了。

希望這可以幫助,

或通過css設置默認值

.note-editor .note-editable {
    line-height: 1.2;
    font-size: 18px;
}

您可以設置當前所選文本的字體大小,

$('.summernote').summernote('fontSize', 40);

但似乎沒有API來選擇文本。

無法設置默認字體大小非常奇怪,所以我在他們的回購中提出了一個問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM