Changeset 384


Ignore:
Timestamp:
10/05/05 14:28:42 (14 years ago)
Author:
wymsy
Message:

Added support for document fragments in Gecko
Added support for htmlRemoveTags config option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/GetHtml/get-html.js

    r358 r384  
    1414  *   - Preserves script and pre formatting 
    1515  *   - Removes contenteditable from body tag in full-page mode 
     16  *   - Supports only7BitPrintablesInURLs config option 
     17  *   - Supports htmlRemoveTags config option 
    1618  */ 
    1719   
     
    123125HTMLArea.getHTML = function(root, outputRoot, editor) { 
    124126        var html = ""; 
    125         var closed; 
    126         var root_tag = (root.nodeType == 1) ? root.tagName.toLowerCase() : ''; //what is this for?? 
     127 
     128        if(root.nodeType == 11) {//document fragment 
     129            //we can't get innerHTML from the root (type 11) node, so we  
     130            //copy all the child nodes into a new div and get innerHTML from the div 
     131            var div = document.createElement("div"); 
     132            var temp = root.insertBefore(div,root.firstChild); 
     133            for (j = temp.nextSibling; j; j = j.nextSibling) {  
     134                        temp.appendChild(j.cloneNode(true)); 
     135            } 
     136            html += temp.innerHTML.replace(/<[^\?][^>]*>/gi, function(tag){return editor.cleanHTML(tag)}); 
     137 
     138        } else { 
     139 
     140        var root_tag = (root.nodeType == 1) ? root.tagName.toLowerCase() : '';  
    127141        if (outputRoot) { //only happens with <html> tag in fullpage mode 
    128                 outputRoot = !(editor.config.htmlRemoveTags && editor.config.htmlRemoveTags.test(root_tag)); 
    129         } 
    130         html = ""; 
    131         if (outputRoot) { 
    132142                html += "<" + root_tag + ">"; 
    133143        } 
     144 
    134145        //pass tags to cleanHTML() one at a time; ignore php tags 
    135         html += editor.getInnerHTML().replace(/<[^\?][^>]*>/gi, function(tag){return editor.cleanHTML(tag)}); 
     146        //includes support for htmlRemoveTags config option 
     147        html += editor.getInnerHTML().replace(/<[^\?][^>]*>/gi, function(tag){ 
     148                if(!(editor.config.htmlRemoveTags && editor.config.htmlRemoveTags.test(tag.replace(/<([^\s>\/]+)/,'$1')))) 
     149                return editor.cleanHTML(tag); 
     150                else return ''}); 
    136151        //IE drops  all </li> tags in a list except the last one 
    137152        if(HTMLArea.is_ie) { 
     
    144159        } 
    145160        html = HTMLArea.indent(html); 
     161} 
    146162//      html = HTMLArea.htmlEncode(html); 
    147163 
Note: See TracChangeset for help on using the changeset viewer.