Index: wysiwyg.js =================================================================== --- wysiwyg.js (revision 291) +++ wysiwyg.js (working copy) @@ -212,6 +212,19 @@ }; /** + * 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. + * + * @param content + * An HTML string to remove tags from. + */ +Drupal.wysiwyg.removeBlankTags = function(content) { + return content.replace(/^(?:
(?: |\s*)<\/p>|
(\r)?(\n)?)$/i, '');
+}
+
+/**
* Allow certain editor libraries to initialize before the DOM is loaded.
*/
Drupal.wysiwygInit();
Index: editors/js/fckeditor-2.6.js
===================================================================
--- editors/js/fckeditor-2.6.js (revision 291)
+++ editors/js/fckeditor-2.6.js (working copy)
@@ -88,7 +88,7 @@
data = Drupal.wysiwyg.plugins[plugin].detach(data, Drupal.settings.wysiwyg.plugins.drupal[plugin], instance.FCK.Name);
}
}
- return data;
+ return Drupal.wysiwyg.removeBlankTags(data);
};
instance.FCK.DataProcessor = new wysiwygDataProcessor();
},
Index: editors/js/ckeditor-3.0.js
===================================================================
--- editors/js/ckeditor-3.0.js (revision 291)
+++ editors/js/ckeditor-3.0.js (working copy)
@@ -79,7 +79,7 @@
pluginsLoaded: function(ev) {
// Override the conversion methods to let Drupal plugins modify the data.
var editor = ev.editor;
- if (editor.dataProcessor && Drupal.settings.wysiwyg.plugins[params.format]) {
+ if (editor.dataProcessor) {
editor.dataProcessor.toHtml = CKEDITOR.tools.override(editor.dataProcessor.toHtml, function(originalToHtml) {
// Convert raw data for display in WYSIWYG mode.
return function(data, fixForBody) {
@@ -101,7 +101,7 @@
data = Drupal.wysiwyg.plugins[plugin].detach(data, Drupal.settings.wysiwyg.plugins.drupal[plugin], editor.name);
}
}
- return data;
+ return Drupal.wysiwyg.removeBlankTags(data);
};
});
}