roojs-bootstrap.js
authorleon <leon@roojs.com>
Mon, 20 Nov 2023 04:53:01 +0000 (12:53 +0800)
committerleon <leon@roojs.com>
Mon, 20 Nov 2023 04:53:01 +0000 (12:53 +0800)
roojs-bootstrap-debug.js

roojs-bootstrap-debug.js
roojs-bootstrap.js

index 3d3f6a2..28da8ca 100644 (file)
@@ -27095,6 +27095,20 @@ Roo.htmleditor.Filter.prototype = {
            
         }
         node.parentNode.removeChild(node);
+    },
+
+    walkTag : function(dom)
+    {
+        if(this.tag === false) {
+            return;
+        }
+
+        var elements = dom.getElementsByTagName(this.tag);
+        Roo.each(Array.from(elements), function(e) {
+            if (this.replaceTag && false === this.replaceTag(e)) {
+                return;
+            }
+        }, this);
     }
 }; 
 
@@ -27372,7 +27386,7 @@ Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack,
 Roo.htmleditor.FilterParagraph = function(cfg)
 {
     // no need to apply config.
-    this.walk(cfg.node);
+    this.walkTag(cfg.node);
 }
 
 Roo.extend(Roo.htmleditor.FilterParagraph, Roo.htmleditor.Filter,
@@ -27393,6 +27407,7 @@ Roo.extend(Roo.htmleditor.FilterParagraph, Roo.htmleditor.Filter,
             node.parentNode.replaceChild(node.ownerDocument.createElement('BR'),node);
             return false; // no need to walk..
         }
+
         var ar = Array.from(node.childNodes);
         for (var i = 0; i < ar.length; i++) {
             node.removeChild(ar[i]);
@@ -27422,7 +27437,8 @@ Roo.extend(Roo.htmleditor.FilterParagraph, Roo.htmleditor.Filter,
  Roo.htmleditor.FilterHashLink = function(cfg)
  {
      // no need to apply config.
-     this.walk(cfg.node);
+    //  this.walk(cfg.node);
+    this.walkTag(cfg.node);
  }
  
  Roo.extend(Roo.htmleditor.FilterHashLink, Roo.htmleditor.Filter,
@@ -27437,17 +27453,11 @@ Roo.extend(Roo.htmleditor.FilterParagraph, Roo.htmleditor.Filter,
              var a = node.attributes[i];
 
              if(a.name.toLowerCase() == 'href' && a.value.startsWith('#')) {
-                 var ar = Array.from(node.childNodes);
-                 for (var i = 0; i < ar.length; i++) {
-                     node.parentNode.insertBefore(ar[i], node);
-                 }
-                 
-                 node.parentNode.removeChild(node);
+                 this.removeNodeKeepChildren(node);
              }
          }
          
          return false;
      }
      
  });/**
@@ -27461,7 +27471,7 @@ Roo.extend(Roo.htmleditor.FilterParagraph, Roo.htmleditor.Filter,
 Roo.htmleditor.FilterSpan = function(cfg)
 {
     // no need to apply config.
-    this.walk(cfg.node);
+    this.walkTag(cfg.node);
 }
 
 Roo.extend(Roo.htmleditor.FilterSpan, Roo.htmleditor.FilterKeepChildren,
@@ -28060,7 +28070,7 @@ Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
 Roo.htmleditor.FilterLongBr = function(cfg)
 {
     // no need to apply config.
-    this.walk(cfg.node);
+    this.walkTag(cfg.node);
 }
 
 Roo.extend(Roo.htmleditor.FilterLongBr, Roo.htmleditor.Filter,
index 9a71a9d..0eb2778 100644 (file)
@@ -1182,7 +1182,7 @@ this.push({type:'endparagraph',pos:this.cpos,row:this.row,col:this.col});}};
 Roo.htmleditor.Filter=function(A){Roo.apply(this.cfg);};Roo.htmleditor.Filter.prototype={node:false,tag:false,replaceComment:false,replaceTag:false,walk:function(A){Roo.each(Array.from(A.childNodes),function(e){switch(true){case e.nodeType==8&&this.replaceComment!==false:this.replaceComment(e);
 return;case e.nodeType!=1:return;case this.tag===true:case e.tagName.indexOf(":")>-1&&typeof(this.tag)=='object'&&this.tag.indexOf(":")>-1:case e.tagName.indexOf(":")>-1&&typeof(this.tag)=='string'&&this.tag==":":case typeof(this.tag)=='object'&&this.tag.indexOf(e.tagName)>-1:case typeof(this.tag)=='string'&&this.tag==e.tagName:if(this.replaceTag&&false===this.replaceTag(e)){return;
 }if(e.hasChildNodes()){this.walk(e);}return;default:if(e.hasChildNodes()){this.walk(e);}}},this);},removeNodeKeepChildren:function(A){ar=Array.from(A.childNodes);for(var i=0;i<ar.length;i++){A.removeChild(ar[i]);A.parentNode.insertBefore(ar[i],A);}A.parentNode.removeChild(A);
-}};
+},walkTag:function(A){if(this.tag===false){return;}var B=A.getElementsByTagName(this.tag);Roo.each(Array.from(B),function(e){if(this.replaceTag&&false===this.replaceTag(e)){return;}},this);}};
 // Roo/htmleditor/FilterAttributes.js
 Roo.htmleditor.FilterAttributes=function(A){Roo.apply(this,A);this.attrib_black=this.attrib_black||[];this.attrib_white=this.attrib_white||[];this.attrib_clean=this.attrib_clean||[];this.style_white=this.style_white||[];this.style_black=this.style_black||[];
 this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterAttributes,Roo.htmleditor.Filter,{tag:true,attrib_black:false,attrib_clean:false,attrib_white:false,style_white:false,style_black:false,replaceTag:function(A){if(!A.attributes||!A.attributes.length){return true;
@@ -1201,14 +1201,14 @@ Roo.htmleditor.FilterKeepChildren=function(A){Roo.apply(this,A);if(this.tag===fa
 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]);
 continue;}}}ar=Array.from(A.childNodes);for(var i=0;i<ar.length;i++){A.removeChild(ar[i]);A.parentNode.insertBefore(ar[i],A);if(this.tag!==false){this.walk(ar[i]);}}A.parentNode.removeChild(A);return false;}});
 // Roo/htmleditor/FilterParagraph.js
-Roo.htmleditor.FilterParagraph=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterParagraph,Roo.htmleditor.Filter,{tag:'P',replaceTag:function(A){if(A.childNodes.length==1&&A.childNodes[0].nodeType==3&&A.childNodes[0].textContent.trim().length<1){A.parentNode.replaceChild(A.ownerDocument.createElement('BR'),A);
+Roo.htmleditor.FilterParagraph=function(A){this.walkTag(A.node);};Roo.extend(Roo.htmleditor.FilterParagraph,Roo.htmleditor.Filter,{tag:'P',replaceTag:function(A){if(A.childNodes.length==1&&A.childNodes[0].nodeType==3&&A.childNodes[0].textContent.trim().length<1){A.parentNode.replaceChild(A.ownerDocument.createElement('BR'),A);
 return false;}var ar=Array.from(A.childNodes);for(var i=0;i<ar.length;i++){A.removeChild(ar[i]);A.parentNode.insertBefore(ar[i],A);}A.parentNode.insertBefore(A.ownerDocument.createElement('BR'),A);A.parentNode.insertBefore(A.ownerDocument.createElement('BR'),A);
 A.parentNode.removeChild(A);return false;}});
 // Roo/htmleditor/FilterHashLink.js
-Roo.htmleditor.FilterHashLink=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterHashLink,Roo.htmleditor.Filter,{tag:'A',replaceTag:function(A){for(var i=0;i<A.attributes.length;i++){var a=A.attributes[i];if(a.name.toLowerCase()=='href'&&a.value.startsWith('#')){var ar=Array.from(A.childNodes);
-for(var i=0;i<ar.length;i++){A.parentNode.insertBefore(ar[i],A);}A.parentNode.removeChild(A);}}return false;}});
+Roo.htmleditor.FilterHashLink=function(A){this.walkTag(A.node);};Roo.extend(Roo.htmleditor.FilterHashLink,Roo.htmleditor.Filter,{tag:'A',replaceTag:function(A){for(var i=0;i<A.attributes.length;i++){var a=A.attributes[i];if(a.name.toLowerCase()=='href'&&a.value.startsWith('#')){this.removeNodeKeepChildren(A);
+}}return false;}});
 // Roo/htmleditor/FilterSpan.js
-Roo.htmleditor.FilterSpan=function(A){this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterSpan,Roo.htmleditor.FilterKeepChildren,{tag:'SPAN',replaceTag:function(A){if(A.attributes&&A.attributes.length>0){return true;}Roo.htmleditor.FilterKeepChildren.prototype.replaceTag.call(this,A);
+Roo.htmleditor.FilterSpan=function(A){this.walkTag(A.node);};Roo.extend(Roo.htmleditor.FilterSpan,Roo.htmleditor.FilterKeepChildren,{tag:'SPAN',replaceTag:function(A){if(A.attributes&&A.attributes.length>0){return true;}Roo.htmleditor.FilterKeepChildren.prototype.replaceTag.call(this,A);
 return false;}});
 // Roo/htmleditor/FilterTableWidth.js
 Roo.htmleditor.FilterTableWidth=function(A){this.tag=['TABLE','TD','TR','TH','THEAD','TBODY'];this.walk(A.node);};Roo.extend(Roo.htmleditor.FilterTableWidth,Roo.htmleditor.Filter,{replaceTag:function(A){if(A.hasAttribute('width')){A.removeAttribute('width');
@@ -1240,7 +1240,7 @@ Roo.htmleditor.FilterStyleToTag=function(A){this.tags={B:['fontWeight','bold'],I
 }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/FilterLongBr.js
-Roo.htmleditor.FilterLongBr=function(A){this.walk(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);
+Roo.htmleditor.FilterLongBr=function(A){this.walkTag(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;
 }if(!ps||['BR','H1','H2','H3','H4','H5','H6'].indexOf(ps.tagName)<0){return false;}A.parentNode.removeChild(A);return false;}});
 // Roo/htmleditor/FilterBlock.js