0
votes

I'm trying to populate the style list with custom classes as I used to do on v3 with content_css, but it's not pulling through any styles. I have followed instructions here http://www.tinymce.com/wiki.php/Plugin:importcss. I have importcss included in my plugins list, importcss_append set to true, and content_css and importcss_file_filter set to the correct file, but it doesn't add anything to the Formats list.

tinymce.init({
    'plugins': ["advlist autolink lists link image charmap print preview hr anchor pagebreak",
        "searchreplace wordcount visualblocks visualchars code fullscreen",
        "insertdatetime media nonbreaking save table contextmenu directionality",
        "emoticons template paste textcolor colorpicker textpattern moxiemanager importcss"],
    'relative_urls': false,
    'content_css': '/cms/style/blocks_mce.css',
    'importcss_append': true,
    'importcss_file_filter': '/cms/style/blocks_mce.css',
    'menubar': 'file edit insert view format table tools',
    'toolbar1': 'undo redo | bold italic | styleselect',
    'toolbar2': 'bullist numlist | alignleft aligncenter alignright alignjustify | link forecolor | image'
});

It is definitely finding the CSS file as if I change the path, I get an error in the code saying it can't find the file, however I don't get any new formats listed anywhere.

I can do this to manually add them:

'style_formats': [
    {title: 'test', classes: 'test'}
]

But this doesn't actually apply the style to the text, and I want them to be picked up manually like they used to be.

Any ideas?

2
Do you have any update on this? It seems tinymce-4 is different than v3. But there is no use of defining all css styles manually. I stacked there too.YahyaE

2 Answers

0
votes

This is strange, content_css should work just fine, an alternative way to set style is using

setStyle

Example:

tinyMCE.DOM.setStyle('mydiv', 'background-color', 'red');

Read here: http://www.tinymce.com/wiki.php/API3:method.tinymce.dom.DOMUtils.setStyle

0
votes

It appears that these imported styles will only be available in the styleselect dropdown toolbar item since TinyMCE 4. So you will need to add that to your toolbar.