Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to take heading (h1, h2, h3) directly on toolbar in tinymce 4

Tags:

I wanna change heading (h1,h2,h3) directly on toolbar ( like tinymce version 3) because i use it very much when i create a new artical. I'm trying to search on internet but I didn't find any answers. Please help me. Thanks a lot enter image description here

like image 891
saurom_90 Avatar asked Nov 04 '13 04:11

saurom_90


People also ask

What are H3 heading tags and how to use them?

When you use H3 heading tags, they should support the preceding H2 heading tags and usually include at least one similar keyword. H3 heading tags are a convenient way to use a tiered approach so that more experienced or knowledgeable readers could skip over basic information and go straight for more advanced content.

How to use H2 and H3 subheadings?

You can use H2 and H3 subheadings to introduce different sections of your text. Just like the “How to Structure your Headings” section that you are currently reading, which sits within the “Structuring your Headings” section.

How do I use toolbars in TinyMCE?

TinyMCE configured with the toolbar on the bottom and with options grouped. Instead of cluttering your toolbar with loads of options, you can configure one or more buttons to open up a set of related options. In this example, we’ve declared three toolbar groups - formatgroup, paragraphgroup, and insertgroup.

What are h1 and H2 tags?

H2 tag SEO is slightly different from H1 tags because you can obviously have more of them. The H2 heading tags are the most important subheadings you can use. They break your piece into sections, similar to chapters in a book, and highlight the main points of your content—not just for readers but for search engines as well.


2 Answers

This answer arrives surely late, but maybe it can help others like me, people how are looking for answer for the same question. I read it here: http://blog.ionelmc.ro/2013/10/17/tinymce-formatting-toolbar-buttons/

First, you have to create the plugin:

tinyMCE.PluginManager.add('stylebuttons', function(editor, url) {   ['pre', 'p', 'code', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].forEach(function(name){    editor.addButton("style-" + name, {        tooltip: "Toggle " + name,          text: name.toUpperCase(),          onClick: function() { editor.execCommand('mceToggleFormat', false, name); },          onPostRender: function() {              var self = this, setup = function() {                  editor.formatter.formatChanged(name, function(state) {                      self.active(state);                  });              };              editor.formatter ? setup() : editor.on('init', setup);          }      })   }); }); 

And then use it in your toolbar:

tinyMCE.init({    selector: '#id',    toolbar: "undo redo | style-p style-h1 style-h2 style-h3 style-pre style-code",    plugins: "stylebuttons", }); 
like image 133
Angel Avatar answered Oct 16 '22 05:10

Angel


        tinymce.init({             toolbar: 'undo redo | alignleft aligncenter alignright alignjustify | formatselect fontselect fontsizeselect | bullist numlist | outdent indent',          }); 

This is a quicker way to add H1, Paragraph and other options to your toolbar in TinyMCE 4.

For a full list see: http://www.tinymce.com/wiki.php/Controls Specificly the 'Core' section. That shows the most commonly used tools.

like image 23
guest Avatar answered Oct 16 '22 05:10

guest