Change default font type/size in TinyMCE

橙三吉。 提交于 2019-11-30 11:38:13

Well, there are several content.css and only one is used to style your editor depending on your configuration settings.

You should use the content_css configuration option and name an own css file where you can overwrite the editors defaults (the content.css you were recently looking for). In your init function use something like

content_css: "http://localhost/css/my_tiny_styles.css",

and in my_tiny_styles.css or whatever file you choose you use

font-family: myfont1, myfont2, sans-serif;
Muthu Krishnan

Here's another way to resolve this problem.

By adding your own custom styles into our CSS file by defining tinymce id.

#tinymce .mceContentBody p {
   font-family: your_font_name !important; 
}

If you want to change the default of the dropboxes rather than the display css only, with tinyMCE 4 it is now:

setup : function(ed) {
 ed.on('init', function(ed) {
  ed.target.editorCommands.execCommand("fontName", false, "Calibri");
  ed.target.editorCommands.execCommand("fontSize", false, "11pt");
 });
}

EDIT: this is the setup option of the init function as explained here: https://www.tinymce.com/docs/configure/integration-and-setup/#setup

For people having troubles adding a stylesheet because of path troubles or whatever reason, this should do it pretty simple:

setup : function(ed) {
     ed.on('init', function(){
         $(this.getDoc()).find('head').append('<style>p{margin:0;}</style>');
     });
}

Note I used jQuery, but can of course be done without it as well.

Here's how to do it without touching CSS or any other codes.

  1. Use the plugin 'TinyMCE Advanced'
  2. Activate it in settings.

More detailed instructions here.

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