2013-04-25 119 views
34

這樣我初始化tinyMCE到textarea。字體,粗體斜體正在工作,但字體大小選擇不起作用。如何在tinyMCE中添加字體大小的工具欄?

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'} 
    ], 
});** 

回答

78

所有你需要做的是添加fontsizeselect到工具欄的配置PARAM:

toolbar: "sizeselect | bold italic | fontselect | fontsizeselect", 

更新:

tinymce.init({ 
    fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt" 
}); 
+0

反正我有12px的展示,而不是「字體大小」的 – Hasnain 2013-04-29 16:05:10

+1

看到我更新的帖子 – Thariama 2013-04-30 05:07:45

3
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 | 
2

我在WordPress的是如何似乎真的惱火努力讓人們想要深入瞭解背景並使用代碼,即使對於像chan這樣的基本功能ging字體。

幸運的是,我找到了一種啓用字體大小菜單而不進行任何真正編碼的方法。

剛 -

  1. 使用插件 'TinyMCE的高級'
  2. 激活它的設置。

More detailed instructions here

3

這可能是有用的角度。下面是我的TinyMCE初始化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 
}); 
相關問題