Is there a way to add a separate class to two different TinyMCE instances on one page?

By default both get "mceContentBody" as the body class.

Can I set each instance to a different value so I can style them differently?

Comments

sun’s picture

Status: Active » Closed (works as designed)

As of now, no. TinyMCE is in control of that IFRAME and Wysiwyg module does not really munge it.

philbar’s picture

Title: Add class to TinyMCE instance » Add body class to TinyMCE instance
Version: 6.x-2.0 » 7.x-2.x-dev
Category: support » feature
Status: Closed (works as designed) » Active

Can we impletement this into TinyMCE's configuration page?

http://www.tinymce.com/wiki.php/Configuration:body_class

TwoD’s picture

Issue summary: View changes
Status: Active » Closed (fixed)

You can set that using hook_wysiwyg_editor_settings_alter();

function mymodule_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'tinymce') {
    $settings['body_class'] = 'foo';
  }
}

Maybe we'll put GUI controls for this setting in later, but it's currently a low priority. I would prefer to build a "custom setting" widget for that GUI first, so you could manually enter the name of the setting you want to change, give Wysiwyg the datatype and a value, and have that sent to the editor with the rest of the settings. That would allow for a much greater flexibility, and we would not have to change the GUI each time editors add or change settings.