📄 overview-summary-tinymce_cleanup.class.js.html
字号:
r.vAttribs = a.reverse();
<span class="comment">//tinyMCE.debug(r.tag, r.oTagName, r.vAttribsRe, r.vAttribsReWC);</span>
} <span class="reserved">else</span> {
r.vAttribsRe = <span class="literal">''</span>;
r.vAttribs = tinyMCE.clearArray(new Array());
r.vAttribsReIsWild = false;
}
or[r.tag] = r;
}
}
<span class="reserved">return</span> or;
},
<span class="comment">/**
* Serializes the specified node as a HTML string. This uses the XML parser and serializer
* to generate a XHTML string.
*
* <span class="attrib">@param</span> {HTMLNode} n Node to serialize as a XHTML string.
* <span class="attrib">@return</span> Serialized XHTML string based on specified node.
* <span class="attrib">@type</span> string
*/</span>
serializeNodeAsXML : <span class="reserved">function</span>(n) {
var s, b;
<span class="reserved">if</span> (!<span class="reserved">this</span>.xmlDoc) {
<span class="reserved">if</span> (<span class="reserved">this</span>.isMSIE) {
try {<span class="reserved">this</span>.xmlDoc = new ActiveXObject(<span class="literal">'MSXML2.DOMDocument'</span>);} catch (e) {}
<span class="reserved">if</span> (!<span class="reserved">this</span>.xmlDoc)
try {<span class="reserved">this</span>.xmlDoc = new ActiveXObject(<span class="literal">'Microsoft.XmlDom'</span>);} catch (e) {}
} <span class="reserved">else</span>
<span class="reserved">this</span>.xmlDoc = document.implementation.createDocument(<span class="literal">''</span>, <span class="literal">''</span>, null);
<span class="reserved">if</span> (!<span class="reserved">this</span>.xmlDoc)
alert(<span class="literal">"Error XML Parser could not be found."</span>);
}
<span class="reserved">if</span> (<span class="reserved">this</span>.xmlDoc.firstChild)
<span class="reserved">this</span>.xmlDoc.removeChild(<span class="reserved">this</span>.xmlDoc.firstChild);
b = <span class="reserved">this</span>.xmlDoc.createElement(<span class="literal">"html"</span>);
b = <span class="reserved">this</span>.xmlDoc.appendChild(b);
<span class="reserved">this</span>._convertToXML(n, b);
<span class="reserved">if</span> (<span class="reserved">this</span>.isMSIE)
<span class="reserved">return</span> <span class="reserved">this</span>.xmlDoc.xml;
<span class="reserved">else</span>
<span class="reserved">return</span> new XMLSerializer().serializeToString(<span class="reserved">this</span>.xmlDoc);
},
<span class="comment">/**
* Converts and adds the specified HTML DOM node to a XML DOM node.
*
* <span class="attrib">@param</span> {HTMLNode} n HTML Node to add as a XML node.
* <span class="attrib">@param</span> {XMLNode} xn XML Node to add the HTML node to.
* <span class="attrib">@private</span>
*/</span>
_convertToXML : <span class="reserved">function</span>(n, xn) {
var xd, el, i, l, cn, at, no, hc = false;
xd = <span class="reserved">this</span>.xmlDoc;
switch (n.nodeType) {
case 1: <span class="comment">// Element</span>
hc = n.hasChildNodes();
el = xd.createElement(n.nodeName.toLowerCase());
at = n.attributes;
<span class="reserved">for</span> (i=at.length-1; i>-1; i--) {
no = at[i];
<span class="reserved">if</span> (no.specified && no.nodeValue)
el.setAttribute(no.nodeName.toLowerCase(), no.nodeValue);
}
<span class="reserved">if</span> (!hc && !<span class="reserved">this</span>.closeElementsRe.test(n.nodeName))
el.appendChild(xd.createTextNode(<span class="literal">""</span>));
xn = xn.appendChild(el);
break;
case 3: <span class="comment">// Text</span>
xn.appendChild(xd.createTextNode(n.nodeValue));
<span class="reserved">return</span>;
case 8: <span class="comment">// Comment</span>
xn.appendChild(xd.createComment(n.nodeValue));
<span class="reserved">return</span>;
}
<span class="reserved">if</span> (hc) {
cn = n.childNodes;
<span class="reserved">for</span> (i=0, l=cn.length; i<l; i++)
<span class="reserved">this</span>._convertToXML(cn[i], xn);
}
},
<span class="comment">/**
* Serializes the specified node as a XHTML string. This uses the TinyMCE serializer logic since it gives more
* control over the output than the build in browser XML serializer.
*
* <span class="attrib">@param</span> {HTMLNode} n Node to serialize as a XHTML string.
* <span class="attrib">@return</span> Serialized XHTML string based on specified node.
* <span class="attrib">@type</span> string
*/</span>
serializeNodeAsHTML : <span class="reserved">function</span>(n) {
var en, no, h = <span class="literal">''</span>, i, l, r, cn, va = false, f = false, at, hc;
switch (n.nodeType) {
case 1: <span class="comment">// Element</span>
hc = n.hasChildNodes();
<span class="reserved">if</span> (<span class="reserved">this</span>.vElementsRe.test(n.nodeName) && (!<span class="reserved">this</span>.iveRe || !<span class="reserved">this</span>.iveRe.test(n.nodeName))) {
va = true;
r = <span class="reserved">this</span>.rules[n.nodeName];
<span class="reserved">if</span> (!r) {
at = <span class="reserved">this</span>.rules;
<span class="reserved">for</span> (no in at) {
<span class="reserved">if</span> (at[no] && at[no].validRe.test(n.nodeName)) {
r = at[no];
break;
}
}
}
en = r.isWild ? n.nodeName.toLowerCase() : r.oTagName;
f = r.fill;
<span class="reserved">if</span> (r.removeEmpty && !hc)
<span class="reserved">return</span> <span class="literal">""</span>;
h += <span class="literal">'<'</span> + en;
<span class="reserved">if</span> (r.vAttribsReIsWild) {
<span class="comment">// Serialize wildcard attributes</span>
at = n.attributes;
<span class="reserved">for</span> (i=at.length-1; i>-1; i--) {
no = at[i];
<span class="reserved">if</span> (no.specified && r.vAttribsRe.test(no.nodeName))
h += <span class="reserved">this</span>._serializeAttribute(n, r, no.nodeName);
}
} <span class="reserved">else</span> {
<span class="comment">// Serialize specific attributes</span>
<span class="reserved">for</span> (i=r.vAttribs.length-1; i>-1; i--)
h += <span class="reserved">this</span>._serializeAttribute(n, r, r.vAttribs[i]);
}
<span class="comment">// Serialize mce_ atts</span>
<span class="reserved">if</span> (!<span class="reserved">this</span>.settings.on_save) {
at = <span class="reserved">this</span>.mceAttribs;
<span class="reserved">for</span> (no in at) {
<span class="reserved">if</span> (at[no])
h += <span class="reserved">this</span>._serializeAttribute(n, r, at[no]);
}
}
<span class="comment">// Close these</span>
<span class="reserved">if</span> (<span class="reserved">this</span>.closeElementsRe.test(n.nodeName))
<span class="reserved">return</span> h + <span class="literal">' />'</span>;
h += <span class="literal">'>'</span>;
<span class="reserved">if</span> (<span class="reserved">this</span>.isMSIE && <span class="reserved">this</span>.codeElementsRe.test(n.nodeName))
h += n.innerHTML;
}
break;
case 3: <span class="comment">// Text</span>
<span class="reserved">if</span> (n.parentNode && <span class="reserved">this</span>.codeElementsRe.test(n.parentNode.nodeName))
<span class="reserved">return</span> <span class="reserved">this</span>.isMSIE ? <span class="literal">''</span> : n.nodeValue;
<span class="reserved">return</span> <span class="reserved">this</span>.xmlEncode(n.nodeValue);
case 8: <span class="comment">// Comment</span>
<span class="reserved">return</span> <span class="literal">"<!--"</span> + n.nodeValue + <span class="literal">"-->"</span>;
}
<span class="reserved">if</span> (hc) {
cn = n.childNodes;
<span class="reserved">for</span> (i=0, l=cn.length; i<l; i++)
h += <span class="reserved">this</span>.serializeNodeAsHTML(cn[i]);
}
<span class="comment">// Fill empty nodes</span>
<span class="reserved">if</span> (f && !hc)
h += <span class="reserved">this</span>.fillStr;
<span class="comment">// End element</span>
<span class="reserved">if</span> (va)
h += <span class="literal">'</'</span> + en + <span class="literal">'>'</span>;
<span class="reserved">return</span> h;
},
<span class="comment">/**
* Serializes the specified attribute as a XHTML string chunk.
*
* <span class="attrib">@param</span> {HTMLNode} n HTML node to get attribute from.
* <span class="attrib">@param</span> {TinyMCE_CleanupRule} r Cleanup rule to use in serialization.
* <span class="attrib">@param</span> {string} an Attribute name to lookfor and serialize.
* <span class="attrib">@return</span> XHTML chunk containing attribute data if it was found.
* <span class="attrib">@type</span> string
* <span class="attrib">@private</span>
*/</span>
_serializeAttribute : <span class="reserved">function</span>(n, r, an) {
var av = <span class="literal">''</span>, t, os = <span class="reserved">this</span>.settings.on_save;
<span class="reserved">if</span> (os && (an.indexOf(<span class="literal">'mce_'</span>) == 0 || an.indexOf(<span class="literal">'_moz'</span>) == 0))
<span class="reserved">return</span> <span class="literal">''</span>;
<span class="reserved">if</span> (os && <span class="reserved">this</span>.mceAttribs[an])
av = <span class="reserved">this</span>._getAttrib(n, <span class="reserved">this</span>.mceAttribs[an]);
<span class="reserved">if</span> (av.length == 0)
av = <span class="reserved">this</span>._getAttrib(n, an);
<span class="reserved">if</span> (av.length == 0 && r.defaultAttribs && (t = r.defaultAttribs[an]))
av = t;
<span class="reserved">if</span> (r.forceAttribs && (t = r.forceAttribs[an]))
av = t;
<span class="reserved">if</span> (os && av.length != 0 && <span class="reserved">this</span>.settings.url_converter.length != 0 && /^(src|href|longdesc)$/.test(an))
av = eval(<span class="reserved">this</span>.settings.url_converter + <span class="literal">'(this, n, av)'</span>);
<span class="reserved">if</span> (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av))
<span class="reserved">return</span> <span class="literal">""</span>;
<span class="reserved">if</span> (av.length != 0 && av == <span class="literal">"{$uid}"</span>)
av = <span class="literal">"uid_"</span> + (<span class="reserved">this</span>.idCount++);
<span class="reserved">if</span> (av.length != 0)
<span class="reserved">return</span> <span class="literal">" "</span> + an + <span class="literal">"="</span> + <span class="literal">'"'</span> + <span class="reserved">this</span>.xmlEncode(av) + <span class="literal">'"'</span>;
<span class="reserved">return</span> <span class="literal">""</span>;
},
<span class="comment">/**
* Applies source formatting/indentation on the specified HTML string.
*
* <span class="attrib">@param</span> {string} h HTML string to apply formatting to.
* <span class="attrib">@return</span> Formatted HTML string.
* <span class="attrib">@type</span> string
*/</span>
formatHTML : <span class="reserved">function</span>(h) {
var s = <span class="reserved">this</span>.settings, p = <span class="literal">''</span>, i = 0, li = 0, o = <span class="literal">''</span>, l;
h = h.replace(/\r/g, <span class="literal">''</span>); <span class="comment">// Windows sux, isn't carriage return a thing of the past :)</span>
h = <span class="literal">'\n'</span> + h;
h = h.replace(new RegExp(<span class="literal">'\\n\\s+'</span>, <span class="literal">'gi'</span>), <span class="literal">'\n'</span>); <span class="comment">// Remove previous formatting</span>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -