X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=Roo%2Fhtmleditor%2FFilterEmpty.js;fp=Roo%2Fhtmleditor%2FFilterEmpty.js;h=383d5aa27ec86e0d0a1bcd2a683a533b28e099c9;hp=642f9925dd0be496d8429a2fc7abb804b3e921c9;hb=8cd3f1abd9357f6b173fbca3cd7324e88b3450ff;hpb=3769ee58189f7ed3b6111f7703411e3ac757bf3e diff --git a/Roo/htmleditor/FilterEmpty.js b/Roo/htmleditor/FilterEmpty.js index 642f9925dd..383d5aa27e 100644 --- a/Roo/htmleditor/FilterEmpty.js +++ b/Roo/htmleditor/FilterEmpty.js @@ -1,6 +1,6 @@ /** * @class Roo.htmleditor.FilterEmpty - * filter empty elements (normally on paste) + * filter empty elements * @constructor * Run a new Empty Filter * @param {Object} config Configuration options @@ -12,22 +12,32 @@ Roo.htmleditor.FilterEmpty = function(cfg) this.walk(cfg.node); } -Roo.extend(Roo.htmleditor.FilterSpan, Roo.htmleditor.FilterBlack, +Roo.extend(Roo.htmleditor.FilterEmpty, Roo.htmleditor.FilterBlack, { - tag : 'B', + tag : true, replaceTag : function(node) { - if (node.innerHTML.trim() != '') { - return true; + // start from leaf node + if(node.hasChildNodes()) { + this.walk(node); } - if (node.attributes && node.attributes.length > 0) { - return true; // walk if there are any. + + // only filter empty leaf element with certain tags + if( + ['B', 'I', 'U', 'S'].indexOf(node.tagName) < 0 + || + node.attributes && node.attributes.length > 0 + || + node.hasChildNodes() + ) { + return false; // don't walk } + Roo.htmleditor.FilterBlack.prototype.replaceTag.call(this, node); - return false; + return false; // don't walk }