Hello all,
I want to be able to add some custom formats to the Tinymce 4 editor. Not much on documentation is out there. Tiny MCE has some on their website but it is poor in explanation.
On Mar 3, 2016, at 9:44 AM, billy kimmel email@hidden wrote:
Hello all,
I want to be able to add some custom formats to the Tinymce 4 editor. Not much on documentation is out there. Tiny MCE has some on their website but it is poor in explanation.
This will create a group of styles with the name “Fonts” which will contain a list of any custom styles you wish to add.
In the Tiny configuration file, or wherever you’re initializing Tiny (you should already know where) you should see the very first tinymce.init line (below). Just add my style_formats code somewhere after that opening line, but before the closing tag. Of course you will want to rename the styles.
For this to work whatever (class) styles you define below must also be present in your stylesheet. So create whatever font styles you want.
Now when a block of text is highlighted in Tiny your class (font) style can be applied to a paragraph which will go from this:
<p>Some text…</p>
to this
<p class-"my-custom-font-style">Some text…</p>
Bear in mind this particular example will only work on paragraph elements.
tinymce.init({
… more stuff here
style_formats: [
{title: ‘Fonts', items: [
{title: 'Font Name 1', block: 'p', classes: 'name_of_class_style_from_stylesheet'},
{title: 'Font Name 2', block: 'p', classes: 'name_of_class_style_from_stylesheet'},
{title: 'Font Name 3', block: 'p', classes: 'name_of_class_style_from_stylesheet'}
]}
],
});
Yes, just define the font as you normally would in the FW styles editor and name it “raleway”. Repeat for other styles/fonts if necessary.
As long as the font can be found (be it Google, embedded…whatever) it should work. I’ve done this very thing numerous times with Tiny 4 and Google fonts.
The initialize code I gave you is javascript. In my apps I use that code in html files to initialize Tiny on-the-fly (via its CDN) and to customize things, just like you’re trying to do. I haven’t used Tiny the “old" way (with files) for a long time.
If you’re using it with WebYep then contact Max, maybe there’s a required step I’m not familiar with. Honestly, using the CDN approach is dead simple. At least the way I’ve been using it.