CSS 如何在 tinyMCE 中添加字体大小工具栏?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16220118/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to add font-size toolbar in tinyMCE?
提问by Hasnain
this way i initialize tinyMCE to a textarea. font, bold italic is working but font size select is not working .
这样我将 tinyMCE 初始化为 textarea。字体,粗斜体有效,但字体大小选择无效。
tinymce.init({
selector: "textarea#content",
theme: "modern",
width: 586,
height: 300,
menubar:false,
font_size_classes : "fontSize1, fontSize2, fontSize3, fontSize4, fontSize5, fontSize6",//i used this line for font sizes
content_css: "css/content.css",
toolbar: "sizeselect | bold italic | fontselect | fontsize",//used font size for showing font size toolbar
style_formats: [
{title: 'Bold text', inline: 'b'},
{title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
{title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
{title: 'Example 1', inline: 'span', classes: 'example1'},
{title: 'Example 2', inline: 'span', classes: 'example2'},
{title: 'Table styles'},
{title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
],
});**
回答by Thariama
All you need to do is to add fontsizeselect
to your toolbar config param:
您需要做的就是添加fontsizeselect
到您的工具栏配置参数:
toolbar: "sizeselect | bold italic | fontselect | fontsizeselect",
Update:
更新:
tinymce.init({
fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt"
});
回答by JGilmartin
This may be of use for perspective. Below is my TinyMCE init JS code which includes the option for font type and size.
这可能对透视有用。下面是我的 TinyMCE init JS 代码,其中包括字体类型和大小的选项。
tinymce.init({
selector: '#articletextarea',
plugins: [
'advlist autolink lists link image charmap preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code',
'insertdatetime media nonbreaking table contextmenu directionality',
'emoticons template paste textcolor colorpicker textpattern imagetools codesample'
],
toolbar: 'codesample | bold italic sizeselect fontselect fontsizeselect | hr alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | insertfile undo redo | forecolor backcolor emoticons | code',
fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt",
height: "350",
menubar: false
});
回答by user1787582
theme_modern_font_sizes: "10px,12px,13px,14px,16px,18px,20px",
font_size_style_values: "12px,13px,14px,16px,18px,20px",
toolbar: "insertfile undo redo | fontsizeselect |
回答by shadowoflight
I'm really annoyed at how wordpress seems to endeavour to make people wanna dig into the background and play with the codes, even for supposedly basic functions like changing fonts.
我真的很恼火 wordpress 似乎努力让人们想要深入了解背景并玩弄代码,即使是更改字体等所谓的基本功能。
Luckily, I found a way to enable the font size menu without doing any real coding.
幸运的是,我找到了一种无需进行任何实际编码即可启用字体大小菜单的方法。
Just -
只是 -
- Use the plugin 'TinyMCE Advanced'
- Activate it in settings.
- 使用插件“TinyMCE Advanced”
- 在设置中激活它。