I've used this module on D6 but just installed it on D7. I'm trying to save a page with <h2> tags in it, but they get converted to <p>s. The same thing happens in both Full HTML mode and Filtered HTML mode (and yes, I've entered the tags I want on Home » Administration » Configuration » Content authoring » Text formats for Filtered HTML!):

1. Open node for editing.
2. h2 isn't a choice in the actual CKEditor menu, so click "disable rich-text"
3. Manually code <h2>s
4. Save and check, they do appear.
5. Re-edit content. When node content opens in CKEditor, <h2> has been changed to <p>.

When I used this module in D6, I could have sworn that styles like <h2> appeared in the Styles menu, and I'm surprised that using Full HTML didn't solve this on the spot. What am I missing?

Comments

TwoD’s picture

Status: Active » Fixed

The format used does not change how the editor itself behaves (unless you're using TinyMCE together with the WYSIWYG Filter module, since it overrides some editor settings based on its filter settings to allow the same tags.).

Selecting a header tag can be done from the Format dropdown (called "HTML block format" under "Buttons and plugins"). Unless that button is enabled, CKEditor (4) will filter out the tag when first loading/parsing the contents since it now considers any tag it won't produce itself as "undesired" by default.

The same thing happens if you disable the editor, input the h2 tag and then re-enable the editor, as that re-initializes it and parses the contents from the textarea again.

This filtering behaviour was a new feature in CKEditor 4 but you should be able to disable or customize it by setting the allowedContent setting to true:

/**
 * Implements hook_wysiwyg_editor_settings_alter().
 */
function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'ckeditor') {
    $settings['allowedContent'] = TRUE;
  }
}

For reference see the CKEditor ACF guide and the CKEDITOR.filter API documentation.

egm’s picture

Thanks for the quick and clear response. I wasn't making the association of these tags as block elements and was trying not to have too many buttons in my toolbar, so I hadn't ticked the right one. All fixed now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.