TinyMCE - Styles menu not working

TinyMCE - Styles menu not working

by ~ Longbarrow ~ -
Number of replies: 6
Hi,

We're testing out the TinyMCE 3 editor in our Moodle. I love the clean code it produces, so I really want to get it working right!

Our TinyMCE "Styles" menu doesn't seem to drop-down - has anyone else had this problem? I think I may be misunderstanding the purpose of the menu. Is it to do with CSS classes/ids ? If so, how do you add styles?

How can I prevent the Styles menu (or certain other buttons) from being shown at all?

Any help would be appreciated,

Thanks!
Average of ratings: -
In reply to ~ Longbarrow ~

Re: TinyMCE - Styles menu not working

by Mauno Korpelainen -

If it is moodle 2.0 you can edit file lib/editor/tinymce/tinymce.js.php and init code.

In row

theme_advanced_buttons1: "fontselect,fontsizeselect,formatselect,styleselect",

removing last ,styleselect removes the list from toolbar and if you want to add styles you need to define them with init code like

theme_advanced_styles : "Header 1=header1;Header 2=header2;Header 3=header3;Table Row=tableRow1",

and define those styles .header1, .header2 etc in style sheets. Usually the style sheet for styles menu is given with

content_css : "mycontent.css",

or

 content_css : "http://yourserver/somepath/mycontent.css",

In moodle 2.0 it's given by

        content_css: "$contentcss",

but $contentcss is probably not defined (yet).

In reply to Mauno Korpelainen

Re: TinyMCE - Styles menu not working

by ~ Longbarrow ~ -
Thanks, but we're using 1.9 - sorry, should have said.
In reply to ~ Longbarrow ~

Re: TinyMCE - Styles menu not working

by Mauno Korpelainen -

Same idea anyway - either you need to find the file(s) where init code is given (if it is Glen's integration the code is in tinymce theme footer.html) or if your tinymce is using advanced theme you can edit editor_template.js (or editor_template_src.js and compress/save it as editor_template.js) - in my test integration last year I used stylemenu for multilang menu but I used also a custom theme instead of advanced theme.

If your tinymce is using advanced theme and you don't give any init code for styleselect default values are taken from editor_template.js, probably

    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",

which shows the select list but does not define the styles and you still need to define those styles (see the previous post)

You could also try to disable styleselect with init code

theme_advanced_disable : "styleselect",

if you don't need it.

In reply to Mauno Korpelainen

Re: TinyMCE - Styles menu not working

by ~ Longbarrow ~ -
Thanks for your help.

Yes, it is Glen's integration code, but I only have ...


theme_advanced_buttons1_add : "fontsizeselect,forecolor,backcolor",

listed.


I think I'm using advanced theme (as you can tell I don't know my way round the code very well), as I have

themes : 'advanced',
languages : 'en',

in the footer.html code.

I have tried taking out the 'styleselect' from the advanced theme editor_template.js and any reference to styles in the footer.html and it still shows.

Do you have any idea where I'm going wrong?
In reply to ~ Longbarrow ~

Re: TinyMCE - Styles menu not working

by Mauno Korpelainen -

In Glen's integration style menu is taken from default settings of advanced theme so all you need to do is edit that init code in footer.html:

Replace row

  theme_advanced_disable : "help,underline,image",

with

  theme_advanced_disable : "help,underline,image,styleselect",

and replace row

  theme_advanced_disable : "help,underline",

with

  theme_advanced_disable : "help,underline,styleselect",

Refresh you browser.

In reply to Mauno Korpelainen

Re: TinyMCE - Styles menu not working

by ~ Longbarrow ~ -
THANKS!!! That worked a treat. big grin big grin

Sorry to have been a bit dim - I blame Fridays and colds and my very, very tiny brain!