繁体   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