Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decrease the line spacing in TinyMCE textarea

I am using TinyMCE to provide a rich text editing text editor. But the line spacing between the lines is too much. I have added a screenshot that shows the line spacing I get on pressing an enter. What can be done about it TinyMCE Screenshot

like image 397
Sachin Avatar asked Dec 11 '11 11:12

Sachin


People also ask

How do I resize TinyMCE?

Clicking and dragging the resize handle in the bottom right-hand corner of the editor.

Does TinyMCE support markdown?

By default, it has basic markdown patterns.


3 Answers

You can add custom css to your CSS-editor like this:

tinyMCE.init({
        ...
        editor_css : "/content_css.css"
});

See docs here: http://www.tinymce.com/wiki.php/Configuration:editor_css

You can then set a line-height property to whatever height you wish in that file.

You can also change a setting where you can switch between generating paragraph tags (p) or linebreak tags (br) with something like this:

tinyMCE.init({
        ...
        force_br_newlines : true,
        force_p_newlines : false,
        forced_root_block : '' // Needed for 3.x
});

See the docs here for more info: http://www.tinymce.com/wiki.php/Configuration:force_br_newlines

I think TinyMCE does paragraphs as standard when you hit enter, that is why you get a big margin between your lines. You can also use shift+enter like in Word to get a new line that is a line break instead of paragraph.

like image 74
span Avatar answered Oct 21 '22 23:10

span


There is a css class that is applied to the TinyMCE html content. It looks like you have <p> tags causing the spacing. Honestly, it looks pretty good to me. But you can override in the css class:

.tinymce-content p {
    padding: 0;
    margin: 2px 0;
}

See the tinymce docs for more info.

like image 22
danludwig Avatar answered Oct 22 '22 01:10

danludwig


You can force TinyMCE to output divs instead of paragraphs. Just put this line in your tinyMCE.init section:

forced_root_block : 'div',
like image 9
Terry Bullock Avatar answered Oct 22 '22 00:10

Terry Bullock