[英]How to set font-size in summernote?
I have been using summernote as my default text editor but I haven't been able to set a particular font-size by default when i initialize it. 我一直使用summernote作为我的默认文本编辑器,但是在初始化时我默认无法设置特定的字体大小。
so far I have tried 到目前为止我试过了
$('.active-textcontainer').summernote({
toolbar: [
['style', ['bold', 'italic', 'underline']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']]
],
height:150,
fontsize:'18px'
});
and 和
$('.active-textcontainer').summernote({
toolbar: [
['style', ['bold', 'italic', 'underline']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']]
],
height:150,
fontsize:'18'
});
Ant help will be appreciated. 蚂蚁帮助将不胜感激。
I've never use summernote
, however looking at the API there is nothing (at least now) to specify default font size, I make a test doing some tries like you and seems that no one works. 我从来没有使用过
summernote
,但是看看API ,没有任何东西(至少现在)指定默认字体大小,我做了一些像你一样尝试的测试,似乎没有人工作。
A possible solution to this is to apply directly the font-size
style to the editor div
using jQuery
because when you initialize summernote
in an object always create the follow div
: <div class="note-editable" ...>...</div>
. 一个可能的解决方案是使用
jQuery
直接将font-size
样式应用于编辑器div
因为当您在对象中初始化summernote
,始终创建以下div
: <div class="note-editable" ...>...</div>
。 So you can do the follow after initialization $('.note-editable').css('font-size','18px');
因此,您可以在初始化后执行以下操作
$('.note-editable').css('font-size','18px');
in your code this could be: 在你的代码中,这可能是:
$('.active-textcontainer').summernote({
toolbar: [
['style', ['bold', 'italic', 'underline']],
['fontsize', ['fontsize']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']]
],
height:150
});
$('.note-editable').css('font-size','18px');
This solution it's a little tricky an if the class
name of the div
editor change on the next version this will not work however maybe it's enough for your case. 这个解决方案有点棘手,如果
div
编辑器的class
名在下一个版本上发生变化,这将无法工作,但是这对你的情况来说已经足够了。
Hope this helps, 希望这可以帮助,
or set the default via css 或通过css设置默认值
.note-editor .note-editable {
line-height: 1.2;
font-size: 18px;
}
You can set the font size of the currently selected text, 您可以设置当前所选文本的字体大小,
$('.summernote').summernote('fontSize', 40);
but there seems to be no API to select text. 但似乎没有API来选择文本。
Being unable to set the default font size is quite strange, so I filed an issue in their repo . 无法设置默认字体大小非常奇怪,所以我在他们的回购中提出了一个问题 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.