diff --git a/wysiwyg.js b/wysiwyg.js index 29e2c54..68d35f2 100644 --- a/wysiwyg.js +++ b/wysiwyg.js @@ -167,6 +167,8 @@ Drupal.wysiwygDetach = function (context, params, trigger) { var editor = Drupal.wysiwyg.instances[params.field].editor; if (jQuery.isFunction(Drupal.wysiwyg.editor.detach[editor])) { Drupal.wysiwyg.editor.detach[editor](context, params, trigger); + var field = $('#' + params.field, context); + field.val(Drupal.wysiwyg.removeBlankTags(field.val())); } }; @@ -257,6 +259,21 @@ Drupal.wysiwyg.getParams = function(element, params) { }; /** + * Removes unwanted 'blank'
and
tags from an HTML string.
+ *
+ * Editors sometimes leave tags like
when nothing was entered. + * This function removes those tags to allow for truly empty fields. + * It also removes an empty div left by Firebug if it was enabled. + * + * @param content + * An HTML string to remove tags from. +*/ +Drupal.wysiwyg.removeBlankTags = function(content) { + content = content.replace(/