fix #8042 - clean up empty tags
authorAlan <alan@roojs.com>
Wed, 28 Feb 2024 08:38:50 +0000 (16:38 +0800)
committerAlan <alan@roojs.com>
Wed, 28 Feb 2024 08:38:50 +0000 (16:38 +0800)
17 files changed:
Roo/HtmlEditorCore.js
Roo/htmleditor/FilterEmpty.js
Roo/htmleditor/FilterStyleToTag.js
buildSDK/dependancy_bootstrap.txt
buildSDK/dependancy_ui.txt
docs/json/roodata.json
docs/src/Roo_HtmlEditorCore.js.html
docs/src/Roo_htmleditor_FilterStyleToTag.js.html
docs/tree.json
examples/test.html
examples/test.js
roojs-all.js
roojs-bootstrap-debug.js
roojs-bootstrap.js
roojs-debug.js
roojs-ui-debug.js
roojs-ui.js

index d426fb9..f8a8164 100644 (file)
@@ -419,6 +419,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
                             ],
                     attrib_clean : ['href', 'src' ] 
                 });
+                new Roo.htmleditor.FilterEmpty({ node : div});
                 
                 var tidy = new Roo.htmleditor.TidySerializer({
                     inner:  true
@@ -736,6 +737,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             new Roo.htmleditor.FilterSpan({ node : d });
             new Roo.htmleditor.FilterLongBr({ node : d });
             new Roo.htmleditor.FilterComment({ node : d });
+            new Roo.htmleditor.FilterEmpty({ node : d});
             
             
         }
index 642f992..383d5aa 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * @class Roo.htmleditor.FilterEmpty
- * filter empty elements (normally <B> 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
      
     }
     
index db7128b..20ba068 100644 (file)
@@ -14,12 +14,12 @@ Roo.htmleditor.FilterStyleToTag = function(cfg)
 {
     
     this.tags = {
-        B  : [ 'fontWeight' , 'bold'],
-        I :  [ 'fontStyle' , 'italic'],
+        B  : [ 'fontWeight' , 'bold', 'font-weight'],
+        I :  [ 'fontStyle' , 'italic', 'font-style'],
         //pre :  [ 'font-style' , 'italic'],
         // h1.. h6 ?? font-size?
-        SUP : [ 'verticalAlign' , 'super' ],
-        SUB : [ 'verticalAlign' , 'sub' ]
+        SUP : [ 'verticalAlign' , 'super', 'vertical-align'],
+        SUB : [ 'verticalAlign' , 'sub', 'vertical-align']
         
         
     };
@@ -52,7 +52,7 @@ Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
         for (var k in this.tags) {
             if (node.style[this.tags[k][0]] == this.tags[k][1]) {
                 inject.push(k);
-                node.style.removeProperty(this.tags[k][0]);
+                node.style.removeProperty(this.tags[k][2]);
             }
         }
         if (!inject.length) {
@@ -65,7 +65,7 @@ Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
             nn.appendChild(nc);
             nn = nc;
         });
-        for(var i = 0;i < cn.length;cn++) {
+        for(var i = 0;i < cn.length;i++) {
             node.removeChild(cn[i]);
             nn.appendChild(cn[i]);
         }
index be94028..34d1a84 100644 (file)
@@ -145,6 +145,7 @@ Roo.htmleditor.Filter
 Roo.htmleditor.FilterAttributes
 Roo.htmleditor.FilterBlack
 Roo.htmleditor.FilterComment
+Roo.htmleditor.FilterEmpty
 Roo.htmleditor.FilterKeepChildren
 Roo.htmleditor.FilterParagraph
 Roo.htmleditor.FilterHashLink
index dcf507c..acbfe60 100644 (file)
@@ -114,6 +114,7 @@ Roo.htmleditor.Filter
 Roo.htmleditor.FilterAttributes
 Roo.htmleditor.FilterBlack
 Roo.htmleditor.FilterComment
+Roo.htmleditor.FilterEmpty
 Roo.htmleditor.FilterKeepChildren
 Roo.htmleditor.FilterParagraph
 Roo.htmleditor.FilterHashLink
index 4993723..4dd59e3 100644 (file)
     "tree_children" : [],
     "tree_parent" : []
   },
+  "Roo.htmleditor.FilterEmpty" : {
+    "props" : [],
+    "events" : [],
+    "methods" : [],
+    "isAbstract" : false,
+    "isBuilderTop" : false,
+    "implementations" : [],
+    "tree_children" : [],
+    "tree_parent" : []
+  },
   "Roo.htmleditor.FilterHashLink" : {
     "props" : [],
     "events" : [],
index 582fd7b..b8c203d 100644 (file)
                             </span><span class="jsdoc-syntax">],
                     </span><span class="jsdoc-var">attrib_clean </span><span class="jsdoc-syntax">: [</span><span class="jsdoc-string">'href'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'src' </span><span class="jsdoc-syntax">]
                 });
+                </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterEmpty</span><span class="jsdoc-syntax">({ </span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">div</span><span class="jsdoc-syntax">});
 
                 </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">tidy </span><span class="jsdoc-syntax">= </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.TidySerializer</span><span class="jsdoc-syntax">({
                     </span><span class="jsdoc-var">inner</span><span class="jsdoc-syntax">:  </span><span class="jsdoc-keyword">true
             </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterSpan</span><span class="jsdoc-syntax">({ </span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">d </span><span class="jsdoc-syntax">});
             </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterLongBr</span><span class="jsdoc-syntax">({ </span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">d </span><span class="jsdoc-syntax">});
             </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterComment</span><span class="jsdoc-syntax">({ </span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">d </span><span class="jsdoc-syntax">});
+            </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterEmpty</span><span class="jsdoc-syntax">({ </span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">d</span><span class="jsdoc-syntax">});
 
 
         }
index 9e9ae4f..3473ecf 100644 (file)
 {
 
     </span><span class="jsdoc-var">this.tags </span><span class="jsdoc-syntax">= {
-        </span><span class="jsdoc-var">B  </span><span class="jsdoc-syntax">: [ </span><span class="jsdoc-string">'fontWeight' </span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'bold'</span><span class="jsdoc-syntax">],
-        </span><span class="jsdoc-var">I </span><span class="jsdoc-syntax">:  [ </span><span class="jsdoc-string">'fontStyle' </span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'italic'</span><span class="jsdoc-syntax">],
+        </span><span class="jsdoc-var">B  </span><span class="jsdoc-syntax">: [ </span><span class="jsdoc-string">'fontWeight' </span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'bold'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'font-weight'</span><span class="jsdoc-syntax">],
+        </span><span class="jsdoc-var">I </span><span class="jsdoc-syntax">:  [ </span><span class="jsdoc-string">'fontStyle' </span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'italic'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'font-style'</span><span class="jsdoc-syntax">],
         </span><span class="jsdoc-comment">//pre :  [ 'font-style' , 'italic'],
         // h1.. h6 ?? font-size?
-        </span><span class="jsdoc-var">SUP </span><span class="jsdoc-syntax">: [ </span><span class="jsdoc-string">'verticalAlign' </span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'super' </span><span class="jsdoc-syntax">],
-        </span><span class="jsdoc-var">SUB </span><span class="jsdoc-syntax">: [ </span><span class="jsdoc-string">'verticalAlign' </span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'sub' </span><span class="jsdoc-syntax">]
+        </span><span class="jsdoc-var">SUP </span><span class="jsdoc-syntax">: [ </span><span class="jsdoc-string">'verticalAlign' </span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'super'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'vertical-align'</span><span class="jsdoc-syntax">],
+        </span><span class="jsdoc-var">SUB </span><span class="jsdoc-syntax">: [ </span><span class="jsdoc-string">'verticalAlign' </span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'sub'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'vertical-align'</span><span class="jsdoc-syntax">]
 
 
     };
@@ -52,7 +52,7 @@
         </span><span class="jsdoc-keyword">for </span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">k </span><span class="jsdoc-keyword">in </span><span class="jsdoc-var">this.tags</span><span class="jsdoc-syntax">) {
             </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">node.style</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">this.tags</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">k</span><span class="jsdoc-syntax">][0]] == </span><span class="jsdoc-var">this.tags</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">k</span><span class="jsdoc-syntax">][1]) {
                 </span><span class="jsdoc-var">inject.push</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">k</span><span class="jsdoc-syntax">);
-                </span><span class="jsdoc-var">node.style.removeProperty</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.tags</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">k</span><span class="jsdoc-syntax">][0]);
+                </span><span class="jsdoc-var">node.style.removeProperty</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.tags</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">k</span><span class="jsdoc-syntax">][2]);
             }
         }
         </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">inject.length</span><span class="jsdoc-syntax">) {
@@ -65,7 +65,7 @@
             </span><span class="jsdoc-var">nn.appendChild</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">nc</span><span class="jsdoc-syntax">);
             </span><span class="jsdoc-var">nn </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">nc</span><span class="jsdoc-syntax">;
         });
-        </span><span class="jsdoc-keyword">for</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">= 0;</span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">&lt; </span><span class="jsdoc-var">cn.length</span><span class="jsdoc-syntax">;</span><span class="jsdoc-var">cn</span><span class="jsdoc-syntax">++) {
+        </span><span class="jsdoc-keyword">for</span><span class="jsdoc-syntax">(</span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">= 0;</span><span class="jsdoc-var">i </span><span class="jsdoc-syntax">&lt; </span><span class="jsdoc-var">cn.length</span><span class="jsdoc-syntax">;</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">++) {
             </span><span class="jsdoc-var">node.removeChild</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">cn</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">]);
             </span><span class="jsdoc-var">nn.appendChild</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">cn</span><span class="jsdoc-syntax">[</span><span class="jsdoc-var">i</span><span class="jsdoc-syntax">]);
         }
index 0306e13..32f9e06 100644 (file)
             "cn" : [],
             "is_class" : false
           },
+          {
+            "name" : "Roo.htmleditor.FilterEmpty",
+            "cn" : [],
+            "is_class" : false
+          },
           {
             "name" : "Roo.htmleditor.FilterHashLink",
             "cn" : [],
index a7ce7a6..f46676f 100644 (file)
@@ -8,19 +8,16 @@
     <link rel="stylesheet" type="text/css" href="examples.css" />
 
      <script type="text/javascript" src="../roojs-debug.js"></script>   
+     <script type="text/javascript" src="../Roo/htmleditor/FilterStyleToTag.js"></script>
+     <script type="text/javascript" src="../Roo/htmleditor/FilterEmpty.js"></script>
      <script type="text/javascript" src="examples.js"></script>
      <script type="text/javascript" src="test.js"></script>
 
 </head>
 <body>
-<h1>Test</h1>
-<br/>
-<br/>
-<a href="#footnote"><sup>abc</sup></a>
-<p>11<span>22</span></p>
-<p> </p>
-<span>33</span>
-<br/>
-b
+<span id='aaa' style="font-weight:bold;"><s>TEST</s><s>BCD</s><s></s></span>
+<span style="font-style:italic; font-weight:bold;"><u></u></span>
+<u>asd</u>
+<s></s>
 </body>
 </html>
index d6a71d2..58a9d07 100644 (file)
@@ -1,6 +1,4 @@
 Roo.onReady(function() {
-    new Roo.htmleditor.FilterHashLink({ node : document.body });
-    new Roo.htmleditor.FilterParagraph({ node : document.body });
-    new Roo.htmleditor.FilterLongBr({ node : document.body });
-    new Roo.htmleditor.FilterSpan({ node : document.body });
+    new Roo.htmleditor.FilterStyleToTag({ node : document.body});
+    new Roo.htmleditor.FilterEmpty({ node : document.body });
 });
\ No newline at end of file
index 6d05efd..80796a5 100644 (file)
@@ -2026,6 +2026,9 @@ var l=p.split(':').shift().replace(/\s+/g,'');l=l.replace(/^\s+/g,'').replace(/\
 Roo.htmleditor.FilterBlack=function(A){Roo.apply(this,A);this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterBlack,Roo.htmleditor.Filter,{tag:true,replaceTag:function(n){n.parentNode.removeChild(n);}});
 // Roo/htmleditor/FilterComment.js
 Roo.htmleditor.FilterComment=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterComment,Roo.htmleditor.Filter,{replaceComment:function(n){n.parentNode.removeChild(n);}});
+// Roo/htmleditor/FilterEmpty.js
+Roo.htmleditor.FilterEmpty=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterEmpty,Roo.htmleditor.FilterBlack,{tag:true,replaceTag:function(A){if(A.hasChildNodes()){this.walk(A);}if(['B','I','U','S'].indexOf(A.tagName)<0||A.attributes&&A.attributes.length>0||A.hasChildNodes()){return false;
+}Roo.htmleditor.FilterBlack.prototype.replaceTag.call(this,A);return false;}});
 // Roo/htmleditor/FilterKeepChildren.js
 Roo.htmleditor.FilterKeepChildren=function(A){Roo.apply(this,A);if(this.tag===false){return;}if((typeof(this.tag)=='object'&&this.tag.indexOf(":")>-1)){this.cleanNamespace=true;}this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterKeepChildren,Roo.htmleditor.FilterBlack,{cleanNamespace:false,replaceTag:function(A){var ar=Array.from(A.childNodes);
 for(var i=0;i<ar.length;i++){var e=ar[i];if(e.nodeType==1){if((typeof(this.tag)=='object'&&this.tag.indexOf(e.tagName)>-1)||(typeof(this.tag)=='string'&&this.tag==e.tagName)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='object'&&this.tag.indexOf(":")>-1)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='string'&&this.tag==":")){this.replaceTag(ar[i]);
@@ -2066,9 +2069,9 @@ return;}var O=N['margin-left'];if(typeof(J[O])=='undefined'){max_margins++;J[O]=
 }var tr=td.parentNode;if(tr.nodeName!='TR'){return;}var D=tr.parentNode;if(D.nodeName!='TBODY'){return;}var E=D.parentNode;if(E.nodeName!='TABLE'){return;}if(E.getElementsByTagName('tr').length!=2){return;}if(E.getElementsByTagName('td').length!=3){return;
 }if(E.innerText.trim()!=''){return;}var p=E.parentNode;C.parentNode.removeChild(C);p.insertBefore(C,E);p.removeChild(E);});}});
 // Roo/htmleditor/FilterStyleToTag.js
-Roo.htmleditor.FilterStyleToTag=function(A){this.tags={B:['fontWeight','bold'],I:['fontStyle','italic'],SUP:['verticalAlign','super'],SUB:['verticalAlign','sub']};Roo.apply(this,A);this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterStyleToTag,Roo.htmleditor.Filter,{tag:true,tags:false,replaceTag:function(A){if(A.getAttribute("style")===null){return true;
-}var B=[];for(var k in this.tags){if(A.style[this.tags[k][0]]==this.tags[k][1]){B.push(k);A.style.removeProperty(this.tags[k][0]);}}if(!B.length){return true;}var cn=Array.from(A.childNodes);var nn=A;Roo.each(B,function(t){var nc=A.ownerDocument.createElement(t);
-nn.appendChild(nc);nn=nc;});for(var i=0;i<cn.length;cn++){A.removeChild(cn[i]);nn.appendChild(cn[i]);}return true}})
+Roo.htmleditor.FilterStyleToTag=function(A){this.tags={B:['fontWeight','bold','font-weight'],I:['fontStyle','italic','font-style'],SUP:['verticalAlign','super','vertical-align'],SUB:['verticalAlign','sub','vertical-align']};Roo.apply(this,A);this.walk(A.node);
+};Roo.extend(Roo.htmleditor.FilterStyleToTag,Roo.htmleditor.Filter,{tag:true,tags:false,replaceTag:function(A){if(A.getAttribute("style")===null){return true;}var B=[];for(var k in this.tags){if(A.style[this.tags[k][0]]==this.tags[k][1]){B.push(k);A.style.removeProperty(this.tags[k][2]);
+}}if(!B.length){return true;}var cn=Array.from(A.childNodes);var nn=A;Roo.each(B,function(t){var nc=A.ownerDocument.createElement(t);nn.appendChild(nc);nn=nc;});for(var i=0;i<cn.length;i++){A.removeChild(cn[i]);nn.appendChild(cn[i]);}return true}})
 // Roo/htmleditor/FilterLongBr.js
 Roo.htmleditor.FilterLongBr=function(A){this.searchTag(A.node);};Roo.extend(Roo.htmleditor.FilterLongBr,Roo.htmleditor.Filter,{tag:'BR',replaceTag:function(A){var ps=A.nextSibling;while(ps&&ps.nodeType==3&&ps.nodeValue.trim().length<1){ps=ps.nextSibling;}if(!ps&&['TD','TH','LI','H1','H2','H3','H4','H5','H6'].indexOf(A.parentNode.tagName)>-1){A.parentNode.removeChild(A);
 return false;}if(!ps||ps.nodeType!=1){return false;}if(!ps||ps.tagName!='BR'){return false;}if(!A.previousSibling){return false;}var ps=A.previousSibling;while(ps&&ps.nodeType==3&&ps.nodeValue.trim().length<1){ps=ps.previousSibling;}if(!ps||ps.nodeType!=1){return false;
@@ -2205,11 +2208,11 @@ catch(e){return;}Roo.TaskMgr.stop(D);this.initEditor.defer(10,this);}},interval:
 return A;},syncValue:function(){if(this.initialized){if(this.undoManager){this.undoManager.addEvent();}var bd=(this.doc.body||this.doc.documentElement);var A=this.win.getSelection();var B=document.createElement('div');B.innerHTML=bd.innerHTML;var C=B.getElementsByClassName('gtx-trans-icon');
 if(C.length>0){var rm=C.item(0).parentNode;rm.parentNode.removeChild(rm);}if(this.enableBlocks){Array.from(bd.getElementsByTagName('img')).forEach(function(F){var G=F.closest('figure');if(G){var bf=new Roo.htmleditor.BlockFigure({node:G});bf.updateElement();
 }});new Roo.htmleditor.FilterBlock({node:B});}var D=B.innerHTML;if(this.autoClean){new Roo.htmleditor.FilterBlack({node:B,tag:this.black});new Roo.htmleditor.FilterAttributes({node:B,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-caption-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']}
-);var E=new Roo.htmleditor.TidySerializer({inner:true});D=E.serialize(B);}if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs?bs.match(/text-align:(.*?);/i):false;if(m&&m[1]){D='<div style="'+m[0]+'">'+D+'</div>';}}D=this.cleanHtml(D);D=D.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g,function(F){var cc=F.charCodeAt();
-if(F.length==2){var G=F.charCodeAt(0)-0xD800;var H=F.charCodeAt(1)-0xDC00;cc=(G*0x400)+H+0x10000;}else if((cc>=0x4E00&&cc<0xA000)||(cc>=0x3400&&cc<0x4E00)||(cc>=0xf900&&cc<0xfb00)){return F;}return "&#"+cc+";";});if(this.owner.fireEvent('beforesync',this,D)!==false){this.el.dom.value=D;
-this.owner.fireEvent('sync',this,D);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value.trim();if(this.owner.fireEvent('beforepush',this,v)!==false){var d=(this.doc.body||this.doc.documentElement);d.innerHTML=v;this.el.dom.value=d.innerHTML;
-this.owner.fireEvent('push',this,v);}if(this.autoClean){new Roo.htmleditor.FilterParagraph({node:this.doc.body});new Roo.htmleditor.FilterSpan({node:this.doc.body});}if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);}this.updateLanguage();
-var lc=this.doc.body.lastChild;if(lc&&lc.nodeType==1&&lc.getAttribute("contenteditable")=="false"){this.doc.body.appendChild(this.doc.createElement('br'));}}},deferFocus:function(){this.focus.defer(10,this);},focus:function(){if(this.win&&!this.sourceEditMode){this.win.focus();
+);new Roo.htmleditor.FilterEmpty({node:B});var E=new Roo.htmleditor.TidySerializer({inner:true});D=E.serialize(B);}if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs?bs.match(/text-align:(.*?);/i):false;if(m&&m[1]){D='<div style="'+m[0]+'">'+D+'</div>';
+}}D=this.cleanHtml(D);D=D.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g,function(F){var cc=F.charCodeAt();if(F.length==2){var G=F.charCodeAt(0)-0xD800;var H=F.charCodeAt(1)-0xDC00;cc=(G*0x400)+H+0x10000;}else if((cc>=0x4E00&&cc<0xA000)||(cc>=0x3400&&cc<0x4E00)||(cc>=0xf900&&cc<0xfb00)){return F;
+}return "&#"+cc+";";});if(this.owner.fireEvent('beforesync',this,D)!==false){this.el.dom.value=D;this.owner.fireEvent('sync',this,D);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value.trim();if(this.owner.fireEvent('beforepush',this,v)!==false){var d=(this.doc.body||this.doc.documentElement);
+d.innerHTML=v;this.el.dom.value=d.innerHTML;this.owner.fireEvent('push',this,v);}if(this.autoClean){new Roo.htmleditor.FilterParagraph({node:this.doc.body});new Roo.htmleditor.FilterSpan({node:this.doc.body});}if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);
+}this.updateLanguage();var lc=this.doc.body.lastChild;if(lc&&lc.nodeType==1&&lc.getAttribute("contenteditable")=="false"){this.doc.body.appendChild(this.doc.createElement('br'));}}},deferFocus:function(){this.focus.defer(10,this);},focus:function(){if(this.win&&!this.sourceEditMode){this.win.focus();
 }else{this.el.focus();}},assignDocWin:function(){var A=this.iframe;if(Roo.isIE){this.doc=A.contentWindow.document;this.win=A.contentWindow;}else{if(!Roo.get(this.frameId)&&!A.contentDocument){return;}this.doc=(A.contentDocument||Roo.get(this.frameId).dom.document);
 this.win=(A.contentWindow||Roo.get(this.frameId).dom.contentWindow);}},initEditor:function(){this.assignDocWin();this.doc.designMode="on";this.doc.open();this.doc.write(this.getDocMarkup());this.doc.close();var A=(this.doc.body||this.doc.documentElement);
 A.bgProperties='fixed';A.setAttribute("translate","no");Roo.EventManager.on(this.doc,{'mouseup':this.onEditorEvent,'dblclick':this.onEditorEvent,'click':this.onEditorEvent,'keyup':this.onEditorEvent,buffer:100,scope:this});Roo.EventManager.on(this.doc,{'paste':this.onPasteEvent,scope:this}
@@ -2222,9 +2225,9 @@ var r=new FileReader();var t=this;r.addEventListener('load',function(){var d=(ne
 this.insertAtCursor("You can not nest tables");return false;}if(B.length>0){var ar=Array.from(d.getElementsByTagName('v:imagedata'));Roo.each(ar,function(E){E.parentNode.insertBefore(d.ownerDocument.createElement('img'),E);E.parentNode.removeChild(E);});Roo.each(d.getElementsByTagName('img'),function(E,i){E.setAttribute('src',B[i]);
 });}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan'],attrib_clean:['href','src']});new Roo.htmleditor.FilterBlack({node:d,tag:this.black}
 );new Roo.htmleditor.FilterKeepChildren({node:d,tag:['FONT',':']});new Roo.htmleditor.FilterParagraph({node:d});new Roo.htmleditor.FilterHashLink({node:d});new Roo.htmleditor.FilterSpan({node:d});new Roo.htmleditor.FilterLongBr({node:d});new Roo.htmleditor.FilterComment({node:d}
-);}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(E){if(E.closest('figure')){return;}var F=new Roo.htmleditor.BlockFigure({image_src:E.src});F.updateElement(E);});}this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);
-}e.preventDefault();this.owner.fireEvent('paste',this);return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));this.activated=true;
-if(Roo.isGecko){this.win.focus();var s=this.win.getSelection();if(!s.focusNode||s.focusNode.nodeType!=3){var r=s.getRangeAt(0);r.selectNodeContents((this.doc.body||this.doc.documentElement));r.collapse(true);this.deferFocus();}try{this.execCmd('useCSS',true);
+);new Roo.htmleditor.FilterEmpty({node:d});}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(E){if(E.closest('figure')){return;}var F=new Roo.htmleditor.BlockFigure({image_src:E.src});F.updateElement(E);});}this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));
+if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);}e.preventDefault();this.owner.fireEvent('paste',this);return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));
+this.activated=true;if(Roo.isGecko){this.win.focus();var s=this.win.getSelection();if(!s.focusNode||s.focusNode.nodeType!=3){var r=s.getRangeAt(0);r.selectNodeContents((this.doc.body||this.doc.documentElement));r.collapse(true);this.deferFocus();}try{this.execCmd('useCSS',true);
 this.execCmd('styleWithCSS',false);}catch(e){}}this.owner.fireEvent('activate',this);},adjustFont:function(A){var B=A.cmd=='increasefontsize'?1:-1;var v=parseInt(this.doc.queryCommandValue('FontSize')||3,10);if(Roo.isSafari){var sm={10:1,13:2,16:3,18:4,24:5,32:6,48:7}
 ;v=(v<10)?10:v;v=(v>48)?48:v;v=typeof(sm[v])=='undefined'?1:sm[v];}v=Math.max(1,v+B);this.execCmd('FontSize',v);},onEditorEvent:function(e){if(e&&(e.ctrlKey||e.metaKey)&&e.keyCode===90){return;}if(e&&e.target.nodeName=='BODY'&&e.type=="mouseup"&&this.doc.body.lastChild){var lc=this.doc.body.lastChild;
 while((lc.nodeType==3&&lc.nodeValue=='')||lc.id=='gtx-trans'){lc=lc.previousSibling;}if(lc.nodeType==1&&lc.nodeName!='BR'){var ns=this.doc.createElement('br');this.doc.body.appendChild(ns);range=this.doc.createRange();range.setStartAfter(ns);range.collapse(true);
index 5df7fa1..657326e 100644 (file)
@@ -27315,6 +27315,49 @@ Roo.extend(Roo.htmleditor.FilterComment, Roo.htmleditor.Filter,
     {
         n.parentNode.removeChild(n);
     }
+});/**
+ * @class Roo.htmleditor.FilterEmpty
+ * filter empty elements
+ * @constructor
+ * Run a new Empty Filter
+ * @param {Object} config Configuration options
+ */
+
+Roo.htmleditor.FilterEmpty = function(cfg)
+{
+    // no need to apply config.
+    this.walk(cfg.node);
+}
+
+Roo.extend(Roo.htmleditor.FilterEmpty, Roo.htmleditor.FilterBlack,
+{
+     
+    tag : true,
+     
+    replaceTag : function(node)
+    {
+        // start from leaf node
+        if(node.hasChildNodes()) {
+            this.walk(node);
+        }
+
+        // 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; // don't walk
+     
+    }
+    
 });/**
  * @class Roo.htmleditor.FilterKeepChildren
  * remove tags but keep children
@@ -28010,12 +28053,12 @@ Roo.htmleditor.FilterStyleToTag = function(cfg)
 {
     
     this.tags = {
-        B  : [ 'fontWeight' , 'bold'],
-        I :  [ 'fontStyle' , 'italic'],
+        B  : [ 'fontWeight' , 'bold', 'font-weight'],
+        I :  [ 'fontStyle' , 'italic', 'font-style'],
         //pre :  [ 'font-style' , 'italic'],
         // h1.. h6 ?? font-size?
-        SUP : [ 'verticalAlign' , 'super' ],
-        SUB : [ 'verticalAlign' , 'sub' ]
+        SUP : [ 'verticalAlign' , 'super', 'vertical-align'],
+        SUB : [ 'verticalAlign' , 'sub', 'vertical-align']
         
         
     };
@@ -28048,7 +28091,7 @@ Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
         for (var k in this.tags) {
             if (node.style[this.tags[k][0]] == this.tags[k][1]) {
                 inject.push(k);
-                node.style.removeProperty(this.tags[k][0]);
+                node.style.removeProperty(this.tags[k][2]);
             }
         }
         if (!inject.length) {
@@ -28061,7 +28104,7 @@ Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
             nn.appendChild(nc);
             nn = nc;
         });
-        for(var i = 0;i < cn.length;cn++) {
+        for(var i = 0;i < cn.length;i++) {
             node.removeChild(cn[i]);
             nn.appendChild(cn[i]);
         }
@@ -31812,6 +31855,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
                             ],
                     attrib_clean : ['href', 'src' ] 
                 });
+                new Roo.htmleditor.FilterEmpty({ node : div});
                 
                 var tidy = new Roo.htmleditor.TidySerializer({
                     inner:  true
@@ -32129,6 +32173,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             new Roo.htmleditor.FilterSpan({ node : d });
             new Roo.htmleditor.FilterLongBr({ node : d });
             new Roo.htmleditor.FilterComment({ node : d });
+            new Roo.htmleditor.FilterEmpty({ node : d});
             
             
         }
index e7186ca..6d372ef 100644 (file)
@@ -1197,6 +1197,9 @@ var l=p.split(':').shift().replace(/\s+/g,'');l=l.replace(/^\s+/g,'').replace(/\
 Roo.htmleditor.FilterBlack=function(A){Roo.apply(this,A);this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterBlack,Roo.htmleditor.Filter,{tag:true,replaceTag:function(n){n.parentNode.removeChild(n);}});
 // Roo/htmleditor/FilterComment.js
 Roo.htmleditor.FilterComment=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterComment,Roo.htmleditor.Filter,{replaceComment:function(n){n.parentNode.removeChild(n);}});
+// Roo/htmleditor/FilterEmpty.js
+Roo.htmleditor.FilterEmpty=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterEmpty,Roo.htmleditor.FilterBlack,{tag:true,replaceTag:function(A){if(A.hasChildNodes()){this.walk(A);}if(['B','I','U','S'].indexOf(A.tagName)<0||A.attributes&&A.attributes.length>0||A.hasChildNodes()){return false;
+}Roo.htmleditor.FilterBlack.prototype.replaceTag.call(this,A);return false;}});
 // Roo/htmleditor/FilterKeepChildren.js
 Roo.htmleditor.FilterKeepChildren=function(A){Roo.apply(this,A);if(this.tag===false){return;}if((typeof(this.tag)=='object'&&this.tag.indexOf(":")>-1)){this.cleanNamespace=true;}this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterKeepChildren,Roo.htmleditor.FilterBlack,{cleanNamespace:false,replaceTag:function(A){var ar=Array.from(A.childNodes);
 for(var i=0;i<ar.length;i++){var e=ar[i];if(e.nodeType==1){if((typeof(this.tag)=='object'&&this.tag.indexOf(e.tagName)>-1)||(typeof(this.tag)=='string'&&this.tag==e.tagName)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='object'&&this.tag.indexOf(":")>-1)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='string'&&this.tag==":")){this.replaceTag(ar[i]);
@@ -1237,9 +1240,9 @@ return;}var O=N['margin-left'];if(typeof(J[O])=='undefined'){max_margins++;J[O]=
 }var tr=td.parentNode;if(tr.nodeName!='TR'){return;}var D=tr.parentNode;if(D.nodeName!='TBODY'){return;}var E=D.parentNode;if(E.nodeName!='TABLE'){return;}if(E.getElementsByTagName('tr').length!=2){return;}if(E.getElementsByTagName('td').length!=3){return;
 }if(E.innerText.trim()!=''){return;}var p=E.parentNode;C.parentNode.removeChild(C);p.insertBefore(C,E);p.removeChild(E);});}});
 // Roo/htmleditor/FilterStyleToTag.js
-Roo.htmleditor.FilterStyleToTag=function(A){this.tags={B:['fontWeight','bold'],I:['fontStyle','italic'],SUP:['verticalAlign','super'],SUB:['verticalAlign','sub']};Roo.apply(this,A);this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterStyleToTag,Roo.htmleditor.Filter,{tag:true,tags:false,replaceTag:function(A){if(A.getAttribute("style")===null){return true;
-}var B=[];for(var k in this.tags){if(A.style[this.tags[k][0]]==this.tags[k][1]){B.push(k);A.style.removeProperty(this.tags[k][0]);}}if(!B.length){return true;}var cn=Array.from(A.childNodes);var nn=A;Roo.each(B,function(t){var nc=A.ownerDocument.createElement(t);
-nn.appendChild(nc);nn=nc;});for(var i=0;i<cn.length;cn++){A.removeChild(cn[i]);nn.appendChild(cn[i]);}return true}})
+Roo.htmleditor.FilterStyleToTag=function(A){this.tags={B:['fontWeight','bold','font-weight'],I:['fontStyle','italic','font-style'],SUP:['verticalAlign','super','vertical-align'],SUB:['verticalAlign','sub','vertical-align']};Roo.apply(this,A);this.walk(A.node);
+};Roo.extend(Roo.htmleditor.FilterStyleToTag,Roo.htmleditor.Filter,{tag:true,tags:false,replaceTag:function(A){if(A.getAttribute("style")===null){return true;}var B=[];for(var k in this.tags){if(A.style[this.tags[k][0]]==this.tags[k][1]){B.push(k);A.style.removeProperty(this.tags[k][2]);
+}}if(!B.length){return true;}var cn=Array.from(A.childNodes);var nn=A;Roo.each(B,function(t){var nc=A.ownerDocument.createElement(t);nn.appendChild(nc);nn=nc;});for(var i=0;i<cn.length;i++){A.removeChild(cn[i]);nn.appendChild(cn[i]);}return true}})
 // Roo/htmleditor/FilterLongBr.js
 Roo.htmleditor.FilterLongBr=function(A){this.searchTag(A.node);};Roo.extend(Roo.htmleditor.FilterLongBr,Roo.htmleditor.Filter,{tag:'BR',replaceTag:function(A){var ps=A.nextSibling;while(ps&&ps.nodeType==3&&ps.nodeValue.trim().length<1){ps=ps.nextSibling;}if(!ps&&['TD','TH','LI','H1','H2','H3','H4','H5','H6'].indexOf(A.parentNode.tagName)>-1){A.parentNode.removeChild(A);
 return false;}if(!ps||ps.nodeType!=1){return false;}if(!ps||ps.tagName!='BR'){return false;}if(!A.previousSibling){return false;}var ps=A.previousSibling;while(ps&&ps.nodeType==3&&ps.nodeValue.trim().length<1){ps=ps.previousSibling;}if(!ps||ps.nodeType!=1){return false;
@@ -1376,11 +1379,11 @@ catch(e){return;}Roo.TaskMgr.stop(D);this.initEditor.defer(10,this);}},interval:
 return A;},syncValue:function(){if(this.initialized){if(this.undoManager){this.undoManager.addEvent();}var bd=(this.doc.body||this.doc.documentElement);var A=this.win.getSelection();var B=document.createElement('div');B.innerHTML=bd.innerHTML;var C=B.getElementsByClassName('gtx-trans-icon');
 if(C.length>0){var rm=C.item(0).parentNode;rm.parentNode.removeChild(rm);}if(this.enableBlocks){Array.from(bd.getElementsByTagName('img')).forEach(function(F){var G=F.closest('figure');if(G){var bf=new Roo.htmleditor.BlockFigure({node:G});bf.updateElement();
 }});new Roo.htmleditor.FilterBlock({node:B});}var D=B.innerHTML;if(this.autoClean){new Roo.htmleditor.FilterBlack({node:B,tag:this.black});new Roo.htmleditor.FilterAttributes({node:B,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-caption-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']}
-);var E=new Roo.htmleditor.TidySerializer({inner:true});D=E.serialize(B);}if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs?bs.match(/text-align:(.*?);/i):false;if(m&&m[1]){D='<div style="'+m[0]+'">'+D+'</div>';}}D=this.cleanHtml(D);D=D.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g,function(F){var cc=F.charCodeAt();
-if(F.length==2){var G=F.charCodeAt(0)-0xD800;var H=F.charCodeAt(1)-0xDC00;cc=(G*0x400)+H+0x10000;}else if((cc>=0x4E00&&cc<0xA000)||(cc>=0x3400&&cc<0x4E00)||(cc>=0xf900&&cc<0xfb00)){return F;}return "&#"+cc+";";});if(this.owner.fireEvent('beforesync',this,D)!==false){this.el.dom.value=D;
-this.owner.fireEvent('sync',this,D);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value.trim();if(this.owner.fireEvent('beforepush',this,v)!==false){var d=(this.doc.body||this.doc.documentElement);d.innerHTML=v;this.el.dom.value=d.innerHTML;
-this.owner.fireEvent('push',this,v);}if(this.autoClean){new Roo.htmleditor.FilterParagraph({node:this.doc.body});new Roo.htmleditor.FilterSpan({node:this.doc.body});}if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);}this.updateLanguage();
-var lc=this.doc.body.lastChild;if(lc&&lc.nodeType==1&&lc.getAttribute("contenteditable")=="false"){this.doc.body.appendChild(this.doc.createElement('br'));}}},deferFocus:function(){this.focus.defer(10,this);},focus:function(){if(this.win&&!this.sourceEditMode){this.win.focus();
+);new Roo.htmleditor.FilterEmpty({node:B});var E=new Roo.htmleditor.TidySerializer({inner:true});D=E.serialize(B);}if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs?bs.match(/text-align:(.*?);/i):false;if(m&&m[1]){D='<div style="'+m[0]+'">'+D+'</div>';
+}}D=this.cleanHtml(D);D=D.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g,function(F){var cc=F.charCodeAt();if(F.length==2){var G=F.charCodeAt(0)-0xD800;var H=F.charCodeAt(1)-0xDC00;cc=(G*0x400)+H+0x10000;}else if((cc>=0x4E00&&cc<0xA000)||(cc>=0x3400&&cc<0x4E00)||(cc>=0xf900&&cc<0xfb00)){return F;
+}return "&#"+cc+";";});if(this.owner.fireEvent('beforesync',this,D)!==false){this.el.dom.value=D;this.owner.fireEvent('sync',this,D);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value.trim();if(this.owner.fireEvent('beforepush',this,v)!==false){var d=(this.doc.body||this.doc.documentElement);
+d.innerHTML=v;this.el.dom.value=d.innerHTML;this.owner.fireEvent('push',this,v);}if(this.autoClean){new Roo.htmleditor.FilterParagraph({node:this.doc.body});new Roo.htmleditor.FilterSpan({node:this.doc.body});}if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);
+}this.updateLanguage();var lc=this.doc.body.lastChild;if(lc&&lc.nodeType==1&&lc.getAttribute("contenteditable")=="false"){this.doc.body.appendChild(this.doc.createElement('br'));}}},deferFocus:function(){this.focus.defer(10,this);},focus:function(){if(this.win&&!this.sourceEditMode){this.win.focus();
 }else{this.el.focus();}},assignDocWin:function(){var A=this.iframe;if(Roo.isIE){this.doc=A.contentWindow.document;this.win=A.contentWindow;}else{if(!Roo.get(this.frameId)&&!A.contentDocument){return;}this.doc=(A.contentDocument||Roo.get(this.frameId).dom.document);
 this.win=(A.contentWindow||Roo.get(this.frameId).dom.contentWindow);}},initEditor:function(){this.assignDocWin();this.doc.designMode="on";this.doc.open();this.doc.write(this.getDocMarkup());this.doc.close();var A=(this.doc.body||this.doc.documentElement);
 A.bgProperties='fixed';A.setAttribute("translate","no");Roo.EventManager.on(this.doc,{'mouseup':this.onEditorEvent,'dblclick':this.onEditorEvent,'click':this.onEditorEvent,'keyup':this.onEditorEvent,buffer:100,scope:this});Roo.EventManager.on(this.doc,{'paste':this.onPasteEvent,scope:this}
@@ -1393,9 +1396,9 @@ var r=new FileReader();var t=this;r.addEventListener('load',function(){var d=(ne
 this.insertAtCursor("You can not nest tables");return false;}if(B.length>0){var ar=Array.from(d.getElementsByTagName('v:imagedata'));Roo.each(ar,function(E){E.parentNode.insertBefore(d.ownerDocument.createElement('img'),E);E.parentNode.removeChild(E);});Roo.each(d.getElementsByTagName('img'),function(E,i){E.setAttribute('src',B[i]);
 });}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan'],attrib_clean:['href','src']});new Roo.htmleditor.FilterBlack({node:d,tag:this.black}
 );new Roo.htmleditor.FilterKeepChildren({node:d,tag:['FONT',':']});new Roo.htmleditor.FilterParagraph({node:d});new Roo.htmleditor.FilterHashLink({node:d});new Roo.htmleditor.FilterSpan({node:d});new Roo.htmleditor.FilterLongBr({node:d});new Roo.htmleditor.FilterComment({node:d}
-);}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(E){if(E.closest('figure')){return;}var F=new Roo.htmleditor.BlockFigure({image_src:E.src});F.updateElement(E);});}this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);
-}e.preventDefault();this.owner.fireEvent('paste',this);return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));this.activated=true;
-if(Roo.isGecko){this.win.focus();var s=this.win.getSelection();if(!s.focusNode||s.focusNode.nodeType!=3){var r=s.getRangeAt(0);r.selectNodeContents((this.doc.body||this.doc.documentElement));r.collapse(true);this.deferFocus();}try{this.execCmd('useCSS',true);
+);new Roo.htmleditor.FilterEmpty({node:d});}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(E){if(E.closest('figure')){return;}var F=new Roo.htmleditor.BlockFigure({image_src:E.src});F.updateElement(E);});}this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));
+if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);}e.preventDefault();this.owner.fireEvent('paste',this);return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));
+this.activated=true;if(Roo.isGecko){this.win.focus();var s=this.win.getSelection();if(!s.focusNode||s.focusNode.nodeType!=3){var r=s.getRangeAt(0);r.selectNodeContents((this.doc.body||this.doc.documentElement));r.collapse(true);this.deferFocus();}try{this.execCmd('useCSS',true);
 this.execCmd('styleWithCSS',false);}catch(e){}}this.owner.fireEvent('activate',this);},adjustFont:function(A){var B=A.cmd=='increasefontsize'?1:-1;var v=parseInt(this.doc.queryCommandValue('FontSize')||3,10);if(Roo.isSafari){var sm={10:1,13:2,16:3,18:4,24:5,32:6,48:7}
 ;v=(v<10)?10:v;v=(v>48)?48:v;v=typeof(sm[v])=='undefined'?1:sm[v];}v=Math.max(1,v+B);this.execCmd('FontSize',v);},onEditorEvent:function(e){if(e&&(e.ctrlKey||e.metaKey)&&e.keyCode===90){return;}if(e&&e.target.nodeName=='BODY'&&e.type=="mouseup"&&this.doc.body.lastChild){var lc=this.doc.body.lastChild;
 while((lc.nodeType==3&&lc.nodeValue=='')||lc.id=='gtx-trans'){lc=lc.previousSibling;}if(lc.nodeType==1&&lc.nodeName!='BR'){var ns=this.doc.createElement('br');this.doc.body.appendChild(ns);range=this.doc.createRange();range.setStartAfter(ns);range.collapse(true);
index 11270b7..3fc2233 100644 (file)
@@ -47920,6 +47920,49 @@ Roo.extend(Roo.htmleditor.FilterComment, Roo.htmleditor.Filter,
     {
         n.parentNode.removeChild(n);
     }
+});/**
+ * @class Roo.htmleditor.FilterEmpty
+ * filter empty elements
+ * @constructor
+ * Run a new Empty Filter
+ * @param {Object} config Configuration options
+ */
+
+Roo.htmleditor.FilterEmpty = function(cfg)
+{
+    // no need to apply config.
+    this.walk(cfg.node);
+}
+
+Roo.extend(Roo.htmleditor.FilterEmpty, Roo.htmleditor.FilterBlack,
+{
+     
+    tag : true,
+     
+    replaceTag : function(node)
+    {
+        // start from leaf node
+        if(node.hasChildNodes()) {
+            this.walk(node);
+        }
+
+        // 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; // don't walk
+     
+    }
+    
 });/**
  * @class Roo.htmleditor.FilterKeepChildren
  * remove tags but keep children
@@ -48615,12 +48658,12 @@ Roo.htmleditor.FilterStyleToTag = function(cfg)
 {
     
     this.tags = {
-        B  : [ 'fontWeight' , 'bold'],
-        I :  [ 'fontStyle' , 'italic'],
+        B  : [ 'fontWeight' , 'bold', 'font-weight'],
+        I :  [ 'fontStyle' , 'italic', 'font-style'],
         //pre :  [ 'font-style' , 'italic'],
         // h1.. h6 ?? font-size?
-        SUP : [ 'verticalAlign' , 'super' ],
-        SUB : [ 'verticalAlign' , 'sub' ]
+        SUP : [ 'verticalAlign' , 'super', 'vertical-align'],
+        SUB : [ 'verticalAlign' , 'sub', 'vertical-align']
         
         
     };
@@ -48653,7 +48696,7 @@ Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
         for (var k in this.tags) {
             if (node.style[this.tags[k][0]] == this.tags[k][1]) {
                 inject.push(k);
-                node.style.removeProperty(this.tags[k][0]);
+                node.style.removeProperty(this.tags[k][2]);
             }
         }
         if (!inject.length) {
@@ -48666,7 +48709,7 @@ Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
             nn.appendChild(nc);
             nn = nc;
         });
-        for(var i = 0;i < cn.length;cn++) {
+        for(var i = 0;i < cn.length;i++) {
             node.removeChild(cn[i]);
             nn.appendChild(cn[i]);
         }
@@ -52417,6 +52460,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
                             ],
                     attrib_clean : ['href', 'src' ] 
                 });
+                new Roo.htmleditor.FilterEmpty({ node : div});
                 
                 var tidy = new Roo.htmleditor.TidySerializer({
                     inner:  true
@@ -52734,6 +52778,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             new Roo.htmleditor.FilterSpan({ node : d });
             new Roo.htmleditor.FilterLongBr({ node : d });
             new Roo.htmleditor.FilterComment({ node : d });
+            new Roo.htmleditor.FilterEmpty({ node : d});
             
             
         }
index 129a74c..8438c71 100644 (file)
@@ -23418,6 +23418,49 @@ Roo.extend(Roo.htmleditor.FilterComment, Roo.htmleditor.Filter,
     {
         n.parentNode.removeChild(n);
     }
+});/**
+ * @class Roo.htmleditor.FilterEmpty
+ * filter empty elements
+ * @constructor
+ * Run a new Empty Filter
+ * @param {Object} config Configuration options
+ */
+
+Roo.htmleditor.FilterEmpty = function(cfg)
+{
+    // no need to apply config.
+    this.walk(cfg.node);
+}
+
+Roo.extend(Roo.htmleditor.FilterEmpty, Roo.htmleditor.FilterBlack,
+{
+     
+    tag : true,
+     
+    replaceTag : function(node)
+    {
+        // start from leaf node
+        if(node.hasChildNodes()) {
+            this.walk(node);
+        }
+
+        // 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; // don't walk
+     
+    }
+    
 });/**
  * @class Roo.htmleditor.FilterKeepChildren
  * remove tags but keep children
@@ -24113,12 +24156,12 @@ Roo.htmleditor.FilterStyleToTag = function(cfg)
 {
     
     this.tags = {
-        B  : [ 'fontWeight' , 'bold'],
-        I :  [ 'fontStyle' , 'italic'],
+        B  : [ 'fontWeight' , 'bold', 'font-weight'],
+        I :  [ 'fontStyle' , 'italic', 'font-style'],
         //pre :  [ 'font-style' , 'italic'],
         // h1.. h6 ?? font-size?
-        SUP : [ 'verticalAlign' , 'super' ],
-        SUB : [ 'verticalAlign' , 'sub' ]
+        SUP : [ 'verticalAlign' , 'super', 'vertical-align'],
+        SUB : [ 'verticalAlign' , 'sub', 'vertical-align']
         
         
     };
@@ -24151,7 +24194,7 @@ Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
         for (var k in this.tags) {
             if (node.style[this.tags[k][0]] == this.tags[k][1]) {
                 inject.push(k);
-                node.style.removeProperty(this.tags[k][0]);
+                node.style.removeProperty(this.tags[k][2]);
             }
         }
         if (!inject.length) {
@@ -24164,7 +24207,7 @@ Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
             nn.appendChild(nc);
             nn = nc;
         });
-        for(var i = 0;i < cn.length;cn++) {
+        for(var i = 0;i < cn.length;i++) {
             node.removeChild(cn[i]);
             nn.appendChild(cn[i]);
         }
@@ -27915,6 +27958,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
                             ],
                     attrib_clean : ['href', 'src' ] 
                 });
+                new Roo.htmleditor.FilterEmpty({ node : div});
                 
                 var tidy = new Roo.htmleditor.TidySerializer({
                     inner:  true
@@ -28232,6 +28276,7 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component,  {
             new Roo.htmleditor.FilterSpan({ node : d });
             new Roo.htmleditor.FilterLongBr({ node : d });
             new Roo.htmleditor.FilterComment({ node : d });
+            new Roo.htmleditor.FilterEmpty({ node : d});
             
             
         }
index 8887fec..45b5682 100644 (file)
@@ -1079,6 +1079,9 @@ var l=p.split(':').shift().replace(/\s+/g,'');l=l.replace(/^\s+/g,'').replace(/\
 Roo.htmleditor.FilterBlack=function(A){Roo.apply(this,A);this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterBlack,Roo.htmleditor.Filter,{tag:true,replaceTag:function(n){n.parentNode.removeChild(n);}});
 // Roo/htmleditor/FilterComment.js
 Roo.htmleditor.FilterComment=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterComment,Roo.htmleditor.Filter,{replaceComment:function(n){n.parentNode.removeChild(n);}});
+// Roo/htmleditor/FilterEmpty.js
+Roo.htmleditor.FilterEmpty=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterEmpty,Roo.htmleditor.FilterBlack,{tag:true,replaceTag:function(A){if(A.hasChildNodes()){this.walk(A);}if(['B','I','U','S'].indexOf(A.tagName)<0||A.attributes&&A.attributes.length>0||A.hasChildNodes()){return false;
+}Roo.htmleditor.FilterBlack.prototype.replaceTag.call(this,A);return false;}});
 // Roo/htmleditor/FilterKeepChildren.js
 Roo.htmleditor.FilterKeepChildren=function(A){Roo.apply(this,A);if(this.tag===false){return;}if((typeof(this.tag)=='object'&&this.tag.indexOf(":")>-1)){this.cleanNamespace=true;}this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterKeepChildren,Roo.htmleditor.FilterBlack,{cleanNamespace:false,replaceTag:function(A){var ar=Array.from(A.childNodes);
 for(var i=0;i<ar.length;i++){var e=ar[i];if(e.nodeType==1){if((typeof(this.tag)=='object'&&this.tag.indexOf(e.tagName)>-1)||(typeof(this.tag)=='string'&&this.tag==e.tagName)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='object'&&this.tag.indexOf(":")>-1)||(e.tagName.indexOf(":")>-1&&typeof(this.tag)=='string'&&this.tag==":")){this.replaceTag(ar[i]);
@@ -1119,9 +1122,9 @@ return;}var O=N['margin-left'];if(typeof(J[O])=='undefined'){max_margins++;J[O]=
 }var tr=td.parentNode;if(tr.nodeName!='TR'){return;}var D=tr.parentNode;if(D.nodeName!='TBODY'){return;}var E=D.parentNode;if(E.nodeName!='TABLE'){return;}if(E.getElementsByTagName('tr').length!=2){return;}if(E.getElementsByTagName('td').length!=3){return;
 }if(E.innerText.trim()!=''){return;}var p=E.parentNode;C.parentNode.removeChild(C);p.insertBefore(C,E);p.removeChild(E);});}});
 // Roo/htmleditor/FilterStyleToTag.js
-Roo.htmleditor.FilterStyleToTag=function(A){this.tags={B:['fontWeight','bold'],I:['fontStyle','italic'],SUP:['verticalAlign','super'],SUB:['verticalAlign','sub']};Roo.apply(this,A);this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterStyleToTag,Roo.htmleditor.Filter,{tag:true,tags:false,replaceTag:function(A){if(A.getAttribute("style")===null){return true;
-}var B=[];for(var k in this.tags){if(A.style[this.tags[k][0]]==this.tags[k][1]){B.push(k);A.style.removeProperty(this.tags[k][0]);}}if(!B.length){return true;}var cn=Array.from(A.childNodes);var nn=A;Roo.each(B,function(t){var nc=A.ownerDocument.createElement(t);
-nn.appendChild(nc);nn=nc;});for(var i=0;i<cn.length;cn++){A.removeChild(cn[i]);nn.appendChild(cn[i]);}return true}})
+Roo.htmleditor.FilterStyleToTag=function(A){this.tags={B:['fontWeight','bold','font-weight'],I:['fontStyle','italic','font-style'],SUP:['verticalAlign','super','vertical-align'],SUB:['verticalAlign','sub','vertical-align']};Roo.apply(this,A);this.walk(A.node);
+};Roo.extend(Roo.htmleditor.FilterStyleToTag,Roo.htmleditor.Filter,{tag:true,tags:false,replaceTag:function(A){if(A.getAttribute("style")===null){return true;}var B=[];for(var k in this.tags){if(A.style[this.tags[k][0]]==this.tags[k][1]){B.push(k);A.style.removeProperty(this.tags[k][2]);
+}}if(!B.length){return true;}var cn=Array.from(A.childNodes);var nn=A;Roo.each(B,function(t){var nc=A.ownerDocument.createElement(t);nn.appendChild(nc);nn=nc;});for(var i=0;i<cn.length;i++){A.removeChild(cn[i]);nn.appendChild(cn[i]);}return true}})
 // Roo/htmleditor/FilterLongBr.js
 Roo.htmleditor.FilterLongBr=function(A){this.searchTag(A.node);};Roo.extend(Roo.htmleditor.FilterLongBr,Roo.htmleditor.Filter,{tag:'BR',replaceTag:function(A){var ps=A.nextSibling;while(ps&&ps.nodeType==3&&ps.nodeValue.trim().length<1){ps=ps.nextSibling;}if(!ps&&['TD','TH','LI','H1','H2','H3','H4','H5','H6'].indexOf(A.parentNode.tagName)>-1){A.parentNode.removeChild(A);
 return false;}if(!ps||ps.nodeType!=1){return false;}if(!ps||ps.tagName!='BR'){return false;}if(!A.previousSibling){return false;}var ps=A.previousSibling;while(ps&&ps.nodeType==3&&ps.nodeValue.trim().length<1){ps=ps.previousSibling;}if(!ps||ps.nodeType!=1){return false;
@@ -1258,11 +1261,11 @@ catch(e){return;}Roo.TaskMgr.stop(D);this.initEditor.defer(10,this);}},interval:
 return A;},syncValue:function(){if(this.initialized){if(this.undoManager){this.undoManager.addEvent();}var bd=(this.doc.body||this.doc.documentElement);var A=this.win.getSelection();var B=document.createElement('div');B.innerHTML=bd.innerHTML;var C=B.getElementsByClassName('gtx-trans-icon');
 if(C.length>0){var rm=C.item(0).parentNode;rm.parentNode.removeChild(rm);}if(this.enableBlocks){Array.from(bd.getElementsByTagName('img')).forEach(function(F){var G=F.closest('figure');if(G){var bf=new Roo.htmleditor.BlockFigure({node:G});bf.updateElement();
 }});new Roo.htmleditor.FilterBlock({node:B});}var D=B.innerHTML;if(this.autoClean){new Roo.htmleditor.FilterBlack({node:B,tag:this.black});new Roo.htmleditor.FilterAttributes({node:B,attrib_white:['href','src','name','align','colspan','rowspan','data-display','data-caption-display','data-width','data-caption','start','style','class','allowfullscreen','frameborder','width','height','alt'],attrib_clean:['href','src']}
-);var E=new Roo.htmleditor.TidySerializer({inner:true});D=E.serialize(B);}if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs?bs.match(/text-align:(.*?);/i):false;if(m&&m[1]){D='<div style="'+m[0]+'">'+D+'</div>';}}D=this.cleanHtml(D);D=D.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g,function(F){var cc=F.charCodeAt();
-if(F.length==2){var G=F.charCodeAt(0)-0xD800;var H=F.charCodeAt(1)-0xDC00;cc=(G*0x400)+H+0x10000;}else if((cc>=0x4E00&&cc<0xA000)||(cc>=0x3400&&cc<0x4E00)||(cc>=0xf900&&cc<0xfb00)){return F;}return "&#"+cc+";";});if(this.owner.fireEvent('beforesync',this,D)!==false){this.el.dom.value=D;
-this.owner.fireEvent('sync',this,D);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value.trim();if(this.owner.fireEvent('beforepush',this,v)!==false){var d=(this.doc.body||this.doc.documentElement);d.innerHTML=v;this.el.dom.value=d.innerHTML;
-this.owner.fireEvent('push',this,v);}if(this.autoClean){new Roo.htmleditor.FilterParagraph({node:this.doc.body});new Roo.htmleditor.FilterSpan({node:this.doc.body});}if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);}this.updateLanguage();
-var lc=this.doc.body.lastChild;if(lc&&lc.nodeType==1&&lc.getAttribute("contenteditable")=="false"){this.doc.body.appendChild(this.doc.createElement('br'));}}},deferFocus:function(){this.focus.defer(10,this);},focus:function(){if(this.win&&!this.sourceEditMode){this.win.focus();
+);new Roo.htmleditor.FilterEmpty({node:B});var E=new Roo.htmleditor.TidySerializer({inner:true});D=E.serialize(B);}if(Roo.isSafari){var bs=bd.getAttribute('style');var m=bs?bs.match(/text-align:(.*?);/i):false;if(m&&m[1]){D='<div style="'+m[0]+'">'+D+'</div>';
+}}D=this.cleanHtml(D);D=D.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g,function(F){var cc=F.charCodeAt();if(F.length==2){var G=F.charCodeAt(0)-0xD800;var H=F.charCodeAt(1)-0xDC00;cc=(G*0x400)+H+0x10000;}else if((cc>=0x4E00&&cc<0xA000)||(cc>=0x3400&&cc<0x4E00)||(cc>=0xf900&&cc<0xfb00)){return F;
+}return "&#"+cc+";";});if(this.owner.fireEvent('beforesync',this,D)!==false){this.el.dom.value=D;this.owner.fireEvent('sync',this,D);}}},pushValue:function(){if(this.initialized){var v=this.el.dom.value.trim();if(this.owner.fireEvent('beforepush',this,v)!==false){var d=(this.doc.body||this.doc.documentElement);
+d.innerHTML=v;this.el.dom.value=d.innerHTML;this.owner.fireEvent('push',this,v);}if(this.autoClean){new Roo.htmleditor.FilterParagraph({node:this.doc.body});new Roo.htmleditor.FilterSpan({node:this.doc.body});}if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);
+}this.updateLanguage();var lc=this.doc.body.lastChild;if(lc&&lc.nodeType==1&&lc.getAttribute("contenteditable")=="false"){this.doc.body.appendChild(this.doc.createElement('br'));}}},deferFocus:function(){this.focus.defer(10,this);},focus:function(){if(this.win&&!this.sourceEditMode){this.win.focus();
 }else{this.el.focus();}},assignDocWin:function(){var A=this.iframe;if(Roo.isIE){this.doc=A.contentWindow.document;this.win=A.contentWindow;}else{if(!Roo.get(this.frameId)&&!A.contentDocument){return;}this.doc=(A.contentDocument||Roo.get(this.frameId).dom.document);
 this.win=(A.contentWindow||Roo.get(this.frameId).dom.contentWindow);}},initEditor:function(){this.assignDocWin();this.doc.designMode="on";this.doc.open();this.doc.write(this.getDocMarkup());this.doc.close();var A=(this.doc.body||this.doc.documentElement);
 A.bgProperties='fixed';A.setAttribute("translate","no");Roo.EventManager.on(this.doc,{'mouseup':this.onEditorEvent,'dblclick':this.onEditorEvent,'click':this.onEditorEvent,'keyup':this.onEditorEvent,buffer:100,scope:this});Roo.EventManager.on(this.doc,{'paste':this.onPasteEvent,scope:this}
@@ -1275,9 +1278,9 @@ var r=new FileReader();var t=this;r.addEventListener('load',function(){var d=(ne
 this.insertAtCursor("You can not nest tables");return false;}if(B.length>0){var ar=Array.from(d.getElementsByTagName('v:imagedata'));Roo.each(ar,function(E){E.parentNode.insertBefore(d.ownerDocument.createElement('img'),E);E.parentNode.removeChild(E);});Roo.each(d.getElementsByTagName('img'),function(E,i){E.setAttribute('src',B[i]);
 });}if(this.autoClean){new Roo.htmleditor.FilterWord({node:d});new Roo.htmleditor.FilterStyleToTag({node:d});new Roo.htmleditor.FilterAttributes({node:d,attrib_white:['href','src','name','align','colspan','rowspan'],attrib_clean:['href','src']});new Roo.htmleditor.FilterBlack({node:d,tag:this.black}
 );new Roo.htmleditor.FilterKeepChildren({node:d,tag:['FONT',':']});new Roo.htmleditor.FilterParagraph({node:d});new Roo.htmleditor.FilterHashLink({node:d});new Roo.htmleditor.FilterSpan({node:d});new Roo.htmleditor.FilterLongBr({node:d});new Roo.htmleditor.FilterComment({node:d}
-);}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(E){if(E.closest('figure')){return;}var F=new Roo.htmleditor.BlockFigure({image_src:E.src});F.updateElement(E);});}this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);
-}e.preventDefault();this.owner.fireEvent('paste',this);return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));this.activated=true;
-if(Roo.isGecko){this.win.focus();var s=this.win.getSelection();if(!s.focusNode||s.focusNode.nodeType!=3){var r=s.getRangeAt(0);r.selectNodeContents((this.doc.body||this.doc.documentElement));r.collapse(true);this.deferFocus();}try{this.execCmd('useCSS',true);
+);new Roo.htmleditor.FilterEmpty({node:d});}if(this.enableBlocks){Array.from(d.getElementsByTagName('img')).forEach(function(E){if(E.closest('figure')){return;}var F=new Roo.htmleditor.BlockFigure({image_src:E.src});F.updateElement(E);});}this.insertAtCursor(d.innerHTML.replace(/&nbsp;/g,' '));
+if(this.enableBlocks){Roo.htmleditor.Block.initAll(this.doc.body);}e.preventDefault();this.owner.fireEvent('paste',this);return false;},onDestroy:function(){if(this.rendered){}},onFirstFocus:function(){this.assignDocWin();this.undoManager=new Roo.lib.UndoManager(100,(this.doc.body||this.doc.documentElement));
+this.activated=true;if(Roo.isGecko){this.win.focus();var s=this.win.getSelection();if(!s.focusNode||s.focusNode.nodeType!=3){var r=s.getRangeAt(0);r.selectNodeContents((this.doc.body||this.doc.documentElement));r.collapse(true);this.deferFocus();}try{this.execCmd('useCSS',true);
 this.execCmd('styleWithCSS',false);}catch(e){}}this.owner.fireEvent('activate',this);},adjustFont:function(A){var B=A.cmd=='increasefontsize'?1:-1;var v=parseInt(this.doc.queryCommandValue('FontSize')||3,10);if(Roo.isSafari){var sm={10:1,13:2,16:3,18:4,24:5,32:6,48:7}
 ;v=(v<10)?10:v;v=(v>48)?48:v;v=typeof(sm[v])=='undefined'?1:sm[v];}v=Math.max(1,v+B);this.execCmd('FontSize',v);},onEditorEvent:function(e){if(e&&(e.ctrlKey||e.metaKey)&&e.keyCode===90){return;}if(e&&e.target.nodeName=='BODY'&&e.type=="mouseup"&&this.doc.body.lastChild){var lc=this.doc.body.lastChild;
 while((lc.nodeType==3&&lc.nodeValue=='')||lc.id=='gtx-trans'){lc=lc.previousSibling;}if(lc.nodeType==1&&lc.nodeName!='BR'){var ns=this.doc.createElement('br');this.doc.body.appendChild(ns);range=this.doc.createRange();range.setStartAfter(ns);range.collapse(true);