Allowing Additional CSS Classes in GT Editor [Drupal 7]

Category
Drupal Version
Tags

Are you adding design elements with CSS and want editors to be able to use your new CSS classes within GT Editor?  You may have discovered that those classes are being stripped out when the page is saved.  What's happening is that GT Editor operates on a whitelist principle to keep your site and its content safe. You must add any elements, classes, etc. that you want to use to the editor's whitelist - otherwise, it will assume the worst and remove them when you save a page.  GT Editor strips all non-whitelisted classes and elements using the WYSIWYG Filter module. This module is configured within each text format (such as the "basic text editor" format that comes standard in GT Editor).

The Easy Way: Use Standard "gt-ed-*" Class Naming

The latest versions of GT Editor (7.x-2.0-beta1 and above) will allow any CSS class that starts with "gt-ed-".  So, if you don't mind adding CSS classes that use this naming format, you're done.

Create Your Own Text Format

If you want to use CSS classes that aren't in the "gt-ed-" naming format, you will need to create your own text format (at admin/config/content/formats). This way, any changes you make to the format won't be overwritten when you update the GT Editor.

It is recommended that you copy the settings from the existing basic text editor text format into your new format, and THEN make changes. If you take this approach, you'll need to remember to integrate changes to this format from each new GT Editor version.

To add to the whitelist of classes, look under your text format's WYSIWYG Filter settings at: admin/config/content/formats/text_editor_basic. You will see sections called Rules for Class Names and Rules for Element IDs where these filters are configured.