gpt4 book ai didi

javascript - 如何在 summernote 中设置字体大小?

转载 作者:数据小太阳 更新时间:2023-10-29 05:12:24 33 4
gpt4 key购买 nike

我一直在使用 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'
});

Ant 帮助将不胜感激。

最佳答案

我从来没有用过summernote , 但是看着 API没有任何东西(至少现在)可以指定默认字体大小,我做了一个测试,像你一样做了一些尝试,但似乎没有人工作。

一个可能的解决方案是直接应用 font-size给编辑的风格div使用 jQuery因为当你初始化 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');

如果class,这个解决方案有点棘手div 的名称下一个版本的编辑器更改这将不起作用,但对于您的情况来说可能就足够了。

希望对您有所帮助,

关于javascript - 如何在 summernote 中设置字体大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27011485/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com