diff --git a/aloha.module b/aloha.module
index b8b5127..b803d89 100644
--- a/aloha.module
+++ b/aloha.module
@@ -371,6 +371,9 @@ function aloha_element_info_alter(&$types) {
  * Uses the element's #id as reference to attach Aloha Editor.
  */
 function aloha_pre_render_text_format($element) {
+  $formats = &drupal_static(__FUNCTION__, array());
+  $module_settings = array();
+
   // filter_process_format() copies properties to the expanded 'value' child
   // element. Skip this text format widget, if it contains no 'format' or when
   // the current user does not have access to edit the value.
@@ -395,19 +398,28 @@ function aloha_pre_render_text_format($element) {
   // @todo This needs to be provided by the filter system.
   // @see http://drupal.org/node/1782838
   foreach ($format_field['format']['#options'] as $format_id => $format_name) {
-    $filter_types = filter_get_filter_types_by_format($format_id);
-    $allowed_tags = filter_get_allowed_tags_by_format($format_id);
-    $no_disallowed_tags = $allowed_tags === TRUE;
-    $necessary_tags_allowed = $no_disallowed_tags || (in_array('br', $allowed_tags) && in_array('p', $allowed_tags));
-    $settings[$format_id] = array(
-      // Aloha Editor should only be enabled if no "HTML generator" filters are
-      // used in this format, and the <br> and <p> tags are allowed.
-      'status' => !in_array(FILTER_TYPE_HTML_GENERATOR, $filter_types)
-                  && $necessary_tags_allowed,
-      // Let Aloha Editor know which tags are allowed; it will reconfigure its
-      // UI to match that.
-      'allowedTags' => implode(',', $no_disallowed_tags ? array() : $allowed_tags),
-    );
+    if (!isset($formats[$format_id])) {
+      $filter_types = filter_get_filter_types_by_format($format_id);
+      $allowed_tags = filter_get_allowed_tags_by_format($format_id);
+      $no_disallowed_tags = $allowed_tags === TRUE;
+      $necessary_tags_allowed = $no_disallowed_tags || (in_array('br', $allowed_tags) && in_array('p', $allowed_tags));
+      $class_name = 'text-format-' . drupal_html_class($format_id);
+      $formats[$format_id] = array(
+        // Aloha Editor should only be enabled if no "HTML generator" filters
+        // are used in this format, and the <br> and <p> tags are allowed.
+        'status' => !in_array(FILTER_TYPE_HTML_GENERATOR, $filter_types)
+        && $necessary_tags_allowed,
+        // Let Aloha Editor know which tags are allowed; it will reconfigure its
+        // UI to match that.
+        'allowedTags' => implode(',', $no_disallowed_tags ? array() : $allowed_tags),
+        'class' => $class_name,
+      );
+      $filter_settings = module_invoke_all('aloha_filter_settings', $format_id, '.' . $class_name);
+      if ($filter_settings) {
+        $module_settings = array_merge_recursive($module_settings, $filter_settings);
+      }
+    }
+    $settings[$format_id] = $format_id;
   }
 
   // Use a hidden element for a single text format.
@@ -427,9 +439,15 @@ function aloha_pre_render_text_format($element) {
         'js' => array(
           array(
             'type' => 'setting',
-            'data' => array('aloha' => array('textareas' => array(
-              $format_field['format']['#id'] => $settings
-            ))),
+            'data' => array(
+              'aloha' => array(
+                'textareas' => array(
+                  $format_field['format']['#id'] => $settings,
+                ),
+                'formats' => $formats,
+                'settings' => $module_settings,
+              ),
+            ),
           ),
         ),
       ),
@@ -441,9 +459,15 @@ function aloha_pre_render_text_format($element) {
     $format_field['format']['#attached']['library'][] = array('aloha', 'aloha-for-textareas');
     $format_field['format']['#attached']['js'][] = array(
       'type' => 'setting',
-      'data' => array('aloha' => array('textareas' => array(
-        $format_field['format']['#id'] => $settings
-      ))),
+      'data' => array(
+        'aloha' => array(
+          'textareas' => array(
+            $format_field['format']['#id'] => $settings,
+          ),
+          'formats' => $formats,
+          'settings' => $module_settings,
+        ),
+      ),
     );
   }
 
diff --git a/js/drupal.aloha.js b/js/drupal.aloha.js
index dea98d6..f197dac 100644
--- a/js/drupal.aloha.js
+++ b/js/drupal.aloha.js
@@ -80,11 +80,10 @@ Drupal.aloha = {
    *   The editable to which Aloha Editor should be applied. Can be a <textarea>
    *   or any HTML tag that contains HTML that should be edited (e.g. <div>,
    *   <article>, etc.) Should have a data-allowed-tags attribute (see README).
-   * @param allowedTags
-   *   An optional allowedTags string, which contains a comma-separated list of
-   *   allowed HTML tags. E.g.: "br,p" or "br,p,strong,em,h1,h2,h3,blockquote".
+   * @param format
+   *   The selected format.
    */
-  attach: function ($editable, allowedTags) {
+  attach: function ($editable, format) {
     var id = $editable.attr('id');
     // If no ID is set on this editable, then generate one.
     if (typeof id === 'undefined' || id === '') {
@@ -92,11 +91,25 @@ Drupal.aloha = {
       $editable.attr('id', id);
     }
 
-    if (allowedTags !== false) {
-      if (typeof allowedTags === 'undefined') {
-        allowedTags = '';
+    // Remove any previous format classes.
+    var formats = Drupal.settings.aloha.formats;
+    for (var text_format in formats) {
+      if (formats.hasOwnProperty(text_format)) {
+        $editable.removeClass(formats[text_format].class);
       }
-      $editable.attr('data-allowed-tags', allowedTags);
+    }
+
+    if (typeof format.class !== 'undefined') {
+      // Add a class for the text format.
+      $editable.addClass(format.class);
+    }
+
+    // $editable.attr('data-text-format-class', format.class);
+    if (format.allowedTags !== false) {
+      if (typeof format.allowedTags === 'undefined') {
+        format.allowedTags = '';
+      }
+      $editable.attr('data-allowed-tags', format.allowedTags);
     }
 
     Aloha.jQuery('#' + id).aloha();
diff --git a/js/drupal.aloha.textarea.js b/js/drupal.aloha.textarea.js
index 091f506..2ddda95 100644
--- a/js/drupal.aloha.textarea.js
+++ b/js/drupal.aloha.textarea.js
@@ -13,22 +13,11 @@ Drupal.behaviors.alohaTextareas = {
         }
         var $this = $(this);
         var params = Drupal.settings.aloha.textareas[this.id];
-        var format;
-        for (format in params) {
-          if (params.hasOwnProperty(format)) {
-            $.extend(params[format], {
-              format: format,
-              trigger: this.id,
-              field: params.field
-            });
-          }
-        }
-        format = this.value;
-        var $editable = $context.find('#' + params[format].field);
-
+        var format = Drupal.settings.aloha.formats[this.value];
+        var $editable = $context.find('#' + params.field);
         // Directly attach this editor, if the input format is enabled.
-        if (params[format].status) {
-          Drupal.aloha.attach($editable, params[format].allowedTags);
+        if (format.status) {
+          Drupal.aloha.attach($editable, format);
 
           // Activate the first Aloha Editor.
           if (first) {
@@ -44,9 +33,9 @@ Drupal.behaviors.alohaTextareas = {
             // Editor; otherwise it would not pick up the changed
             // data-allowed-tags attribute.
             Drupal.aloha.detach($editable);
-            var format = this.value;
-            if (params[format].status) {
-              Drupal.aloha.attach($editable, params[format].allowedTags);
+            var format = Drupal.settings.aloha.formats[this.value];
+            if (format.status) {
+              Drupal.aloha.attach($editable, format);
               Drupal.aloha.activate($editable);
             }
           });
