TinyMCE 4 default font-size

余生长醉 提交于 2019-12-22 08:56:08

问题


In TinyMCE 3 you can change the editor's default font-size by using this code in the settings:

setup : function(ed)
{
    ed.onInit.add(function(ed)
        {
            ed.getDoc().body.style.fontSize = '14px';
        });
}

In version 4, I tried using the same method but get this error:

TypeError: ed.onInit is undefined

I also tried using the "content_css" option and set the body to 14px font size, but that works only when on preview. http://www.tinymce.com/wiki.php/Configuration:content_css

Has anyone found another way to set the editor's default font size? I couldn't find any documents, even in their forum.


回答1:


setup : function(ed)
{
    ed.on('init', function() 
    {
        this.getDoc().body.style.fontSize = '14px';
    });
}



回答2:


tinymce.yml on rails

The function needs to be on the next line, like so:

menubar : false
toolbar: code | bold italic | link image anchor | bullist numlist | undo redo
oninit : "setPlainText"
forced_root_block : false
plugins:
  - paste
  - code
  - link
setup :
  function(ed) {
    ed.on('init', function() 
    {
        this.getDoc().body.style.fontSize = '13px';
    });
  }

Works on TinyMCE 4



来源:https://stackoverflow.com/questions/16803268/tinymce-4-default-font-size

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!