New Landing How can we help? Themeforest Theme Support Flexform Add new style to TinyMCE editor?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Posted in: Flexform
  • #11694
    thewoosh
    Member
    Post count: 27

    Hi,
    I have added a new style to the CSS in Theme/General Options and I would like it to appear in the TinyMCE Styles menu so users can apply it.
    Do you have any suggestions as to how this can be achieved?
    I tried installing TinyMCE Advanced Plugin, but this seems to be incompatible with Flexform, since it broke TinyMCE completely…

    Please also see my other outstanding questions at http://support.swiftideas.net/forums/topic/modify-css/#post-11524

    PS Outstanding Theme!
    Many Thanks,
    Andy

    #36071
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Did you find a solution to this? I have the same problem, installed the plugin and it breaks the visual editor completely.

    #37403
    Swift Ideas – Ed
    Keymaster
    Post count: 15264

    Hi Andy/Kyle,

    Apologies for the delay in reply. We do this with some simple code added to the functions.php file, and you could easily add it in the child theme functions.php file:

    	function sf_custom_mce_styles( $init ) {
    	    $init['theme_advanced_buttons2_add_before'] = 'styleselect';
    	    //First, we define the styles we want to add in format 'Style Name' => 'css classes'
            $classes = array(
                __('Impact Text', 'swift-framework-admin')     => 'impact-text',
                __('Impact Text Large', 'swift-framework-admin')     => 'impact-text-large',
            );
        
            //Delimit styles by semicolon in format 'Title=classes;' so TinyMCE can use it
            if ( ! empty($settings['theme_advanced_styles']) )
            {
                $settings['theme_advanced_styles'] .= ';';
            }
            else
            {
                //If there's nothing defined yet, define it
                $settings['theme_advanced_styles'] = '';
            }
        
            //Loop through our newly defined classes and add them to TinyMCE
            $class_settings = '';
            foreach ( $classes as $name => $value )
            {
                $class_settings .= "{$name}={$value};";
            }
        
            //Add our new class settings to the TinyMCE $settings array
            $settings['theme_advanced_styles'] .= trim($class_settings, '; ');
    
    	    return $init;
    	}
    	 
    	add_filter('tiny_mce_before_init', 'sf_custom_mce_styles');
    	 
    	function sf_mce_css() {
    	    return get_template_directory_uri() . '/css/editor-style.css';
    	}
    	 
    	add_filter( 'mce_css', 'sf_mce_css' );

    Hope that helps!

    – Ed

    #37473
    thewoosh
    Member
    Post count: 27

    Thanks folks,
    6 month support turnaround is better late than never! 🙂
    Obviously the bump last week was useful…
    thewoosh

    #38015
    Melanie – SUPPORT
    Member
    Post count: 11032

    Fantastic!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register