I'm writing a generic plugin and I need to specify extended_valid_elements for TinyMCE. I've looked in the wysiwyg_api.php file and extended_valid_elements are specified in the example. However, I can't seem to get TinyMCE to read it. I took a look at editors/tinymce.inc where extended_valid_elements is merged and the native plugins never get there.

Bug? As designed? User errror?

Comments

jseffel’s picture

As a sidenote, I did this instead:

function MY_MODULE_wysiwyg_editor_settings_alter(&$settings, &$context) {
  if($context['profile']->editor == 'tinymce' && $context['profile']->settings['buttons']['drupal']['MY_PLUGIN']) {
    $settings['extended_valid_elements'] = $settings['extended_valid_elements'] . "," . "MY_ELEMENT[MY_ATTR]";
  }
}
twod’s picture

Status: Active » Postponed (maintainer needs more info)

Hmm, both cross-editor "Drupal plugins" and native plugins' extended_valid_elements should be handled by the same code.
Can you post your hook implementation so I can test with it?

Perhaps this is related to #372165: TinyMCE 3: extended_valid_elements merged wrongly?

sun’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Sorry, without further information this issue can only be closed as not reproducible.

Feel free to re-open this issue if you want to provide further information. Thanks.

deciphered’s picture

Category: support » bug
Status: Closed (cannot reproduce) » Active

I can also confirm that Drupal plugins do not support extended_valid_elements, the problem is that wysiwyg_tinymce_settings loops through $config['buttons'], which in my case the primary keys it returns are default and drupal, meaning that the following code doesn't grab the settings from the Drupal plugins:

          // Allow plugins to add valid HTML elements.
          if (!empty($plugins[$plugin]['extended_valid_elements'])) {
            $settings['extended_valid_elements'] = array_merge($settings['extended_valid_elements'], $plugins[$plugin]['extended_valid_elements']);
          }

Thanks for the temporary workaround jseffel, although I haven't tested it yet, but please in future try to follow up on issues so they can be resolved officially.

Cheers,
Deciphered.