Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default font size in tinymce?

I am using jquery tinymce editor. Default font size is 10. I like to change that default font size. How can i do that,

like image 893
Mohan Ram Avatar asked Dec 13 '10 09:12

Mohan Ram


People also ask

How do you change the font on TinyMCE?

Add a custom font family to the menu TinyMCE comes with 17 font options by default. Depending on the editor configuration, users can select a font from the menubar or the toolbar (via the fontselect dropdown). A user selects a font from the fontselect toolbar menu.

How do I change the height on TinyMCE editor?

Under the hood: You can see string like "height": 120, in data-mce-conf attribute of the generated HTML for the textarea.

How do you change text color on TinyMCE?

This plugin adds the forecolor/backcolor button controls that enable you to pick colors from a color picker and apply these to text. It adds a toolbar button to enable this functionality.


2 Answers

You need to use the content_css setting of tinymce to set a custom css file of your own (make sure this setting points to a valid location of a css file). This file will be inserted in the editor iframes head after all other css settings(files from the core) are inserted there when initialising tinymce - thus all settings you place in your file will overwrite the settings made before (by tinymce).

Example: Setting the default font-size to 11px. Content of a custom css file (i named it content.css in my installation):

body {
    font-family: Verdana,Arial,Helvetica,sans-serif;
    font-size: 11px;
}

How to use this setting:

tinyMCE.init({
 ...
 // you do not need to include it yourself, tinymce will do this for you, 
 // but you will need to give tinymce the location of your css file
 content_css : "http://www.myserver.com/css/content.css", 
     ...
});
like image 143
Thariama Avatar answered Oct 11 '22 19:10

Thariama


I have used in my project in this way

tinymce.init({
  selector:"#txt1",
  setup : function(ed)
  {
    ed.on('init', function() 
    {
        this.execCommand("fontName", false, "tahoma");
        this.execCommand("fontSize", false, "12px");
    });
  }  
}); 

This is the better way than just changing property values in 'content.css'

like image 20
Nishad Up Avatar answered Oct 11 '22 18:10

Nishad Up