src/pyams_skin/resources/js/ext/tinymce/dev/classes/html/DomParser.min.js
changeset 81 472bd9195a15
equal deleted inserted replaced
80:181b3a0ee15a 81:472bd9195a15
       
     1 define("tinymce/html/DomParser",["tinymce/html/Node","tinymce/html/Schema","tinymce/html/SaxParser","tinymce/util/Tools"],function(c,e,a,b){var f=b.makeMap,g=b.each,d=b.explode,h=b.extend;return function(m,n){var l=this,k={},j=[],o={},i={};m=m||{};m.validate="validate" in m?m.validate:true;m.root_name=m.root_name||"body";l.schema=n=n||new e();function p(t){var v,w,C,B,E,u,x,r,A;var q,z,s,D,y;z=f("tr,td,th,tbody,thead,tfoot,table");q=n.getNonEmptyElements();s=n.getTextBlockElements();for(v=0;v<t.length;v++){w=t[v];if(!w.parent||w.fixed){continue}if(s[w.name]&&w.parent.name=="li"){D=w.next;while(D){if(s[D.name]){D.name="li";D.fixed=true;w.parent.insert(D,w.parent)}else{break}D=D.next}w.unwrap(w);continue}B=[w];for(C=w.parent;C&&!n.isValidChild(C.name,w.name)&&!z[C.name];C=C.parent){B.push(C)}if(C&&B.length>1){B.reverse();E=u=l.filterNode(B[0].clone());for(A=0;A<B.length-1;A++){if(n.isValidChild(u.name,B[A].name)){x=l.filterNode(B[A].clone());u.append(x)}else{x=u}for(r=B[A].firstChild;r&&r!=B[A+1];){y=r.next;x.append(r);r=y}u=x}if(!E.isEmpty(q)){C.insert(E,B[0],true);C.insert(w,E)}else{C.insert(w,B[0],true)}C=B[0];if(C.isEmpty(q)||C.firstChild===C.lastChild&&C.firstChild.name==="br"){C.empty().remove()}}else{if(w.parent){if(w.name==="li"){D=w.prev;if(D&&(D.name==="ul"||D.name==="ul")){D.append(w);continue}D=w.next;if(D&&(D.name==="ul"||D.name==="ul")){D.insert(w,D.firstChild,true);continue}w.wrap(l.filterNode(new c("ul",1)));continue}if(n.isValidChild(w.parent.name,"div")&&n.isValidChild("div",w.name)){w.wrap(l.filterNode(new c("div",1)))}else{if(w.name==="style"||w.name==="script"){w.empty().remove()}else{w.unwrap()}}}}}}l.filterNode=function(s){var r,q,t;if(q in k){t=o[q];if(t){t.push(s)}else{o[q]=[s]}}r=j.length;while(r--){q=j[r].name;if(q in s.attributes.map){t=i[q];if(t){t.push(s)}else{i[q]=[s]}}}return s};l.addNodeFilter=function(q,r){g(d(q),function(s){var t=k[s];if(!t){k[s]=t=[]}t.push(r)})};l.addAttributeFilter=function(q,r){g(d(q),function(s){var t;for(t=0;t<j.length;t++){if(j[t].name===s){j[t].callbacks.push(r);return}}j.push({name:s,callbacks:[r]})})};l.parse=function(A,r){var s,N,F,E,H,G,B,w,J,R,D;var t,I,Q=[],P;var y,q,C,x;var u,z,v;r=r||{};o={};i={};t=h(f("script,style,head,html,body,title,meta,param"),n.getBlockElements());z=n.getNonEmptyElements();u=n.children;D=m.validate;v="forced_root_block" in r?r.forced_root_block:m.forced_root_block;x=n.getWhiteSpaceElements();I=/^[ \t\r\n]+/;y=/[ \t\r\n]+$/;q=/[ \t\r\n]+/g;C=/^[ \t\r\n]+$/;function K(){var U=N.firstChild,T,V;function S(W){if(W){U=W.firstChild;if(U&&U.type==3){U.value=U.value.replace(I,"")}U=W.lastChild;if(U&&U.type==3){U.value=U.value.replace(y,"")}}}if(!n.isValidChild(N.name,v.toLowerCase())){return}while(U){T=U.next;if(U.type==3||(U.type==1&&U.name!=="p"&&!t[U.name]&&!U.attr("data-mce-type"))){if(!V){V=O(v,1);V.attr(m.forced_root_block_attrs);N.insert(V,U);V.append(U)}else{V.append(U)}}else{S(V);V=null}U=T}S(V)}function O(S,T){var U=new c(S,T),V;if(S in k){V=o[S];if(V){V.push(U)}else{o[S]=[U]}}return U}function M(U){var V,S,T;for(V=U.prev;V&&V.type===3;){S=V.value.replace(y,"");if(S.length>0){V.value=S;V=V.prev}else{T=V.prev;V.remove();V=T}}}function L(T){var U,S={};for(U in T){if(U!=="li"&&U!="p"){S[U]=T[U]}}return S}s=new a({validate:D,allow_script_urls:m.allow_script_urls,allow_conditional_comments:m.allow_conditional_comments,self_closing_elements:L(n.getSelfClosingElements()),cdata:function(S){F.append(O("#cdata",4)).value=S},text:function(U,S){var T;if(!P){U=U.replace(q," ");if(F.lastChild&&t[F.lastChild.name]){U=U.replace(I,"")}}if(U.length!==0){T=O("#text",3);T.raw=!!S;F.append(T).value=U}},comment:function(S){F.append(O("#comment",8)).value=S},pi:function(S,T){F.append(O(S,7)).value=T;M(F)},doctype:function(T){var S;S=F.append(O("#doctype",10));S.value=T;M(F)},start:function(U,T,Z){var W,S,Y,V,X;Y=D?n.getElementRule(U):{};if(Y){W=O(Y.outputName||U,1);W.attributes=T;W.shortEnded=Z;F.append(W);X=u[F.name];if(X&&u[W.name]&&!X[W.name]){Q.push(W)}S=j.length;while(S--){V=j[S].name;if(V in T.map){J=i[V];if(J){J.push(W)}else{i[V]=[W]}}}if(t[U]){M(W)}if(!Z){F=W}if(!P&&x[U]){P=true}}},end:function(S){var X,U,W,T,V;U=D?n.getElementRule(S):{};if(U){if(t[S]){if(!P){X=F.firstChild;if(X&&X.type===3){W=X.value.replace(I,"");if(W.length>0){X.value=W;X=X.next}else{T=X.next;X.remove();X=T;while(X&&X.type===3){W=X.value;T=X.next;if(W.length===0||C.test(W)){X.remove();X=T}X=T}}}X=F.lastChild;if(X&&X.type===3){W=X.value.replace(y,"");if(W.length>0){X.value=W;X=X.prev}else{T=X.prev;X.remove();X=T;while(X&&X.type===3){W=X.value;T=X.prev;if(W.length===0||C.test(W)){X.remove();X=T}X=T}}}}}if(P&&x[S]){P=false}if(U.removeEmpty||U.paddEmpty){if(F.isEmpty(z)){if(U.paddEmpty){F.empty().append(new c("#text","3")).value="\u00a0"}else{if(!F.attributes.map.name&&!F.attributes.map.id){V=F.parent;if(t[F.name]){F.empty().remove()}else{F.unwrap()}F=V;return}}}}F=F.parent}}},n);N=F=new c(r.context||m.root_name,11);s.parse(A);if(D&&Q.length){if(!r.context){p(Q)}else{r.invalid=true}}if(v&&(N.name=="body"||r.isRootContent)){K()}if(!r.invalid){for(R in o){J=k[R];E=o[R];B=E.length;while(B--){if(!E[B].parent){E.splice(B,1)}}for(H=0,G=J.length;H<G;H++){J[H](E,R,r)}}for(H=0,G=j.length;H<G;H++){J=j[H];if(J.name in i){E=i[J.name];B=E.length;while(B--){if(!E[B].parent){E.splice(B,1)}}for(B=0,w=J.callbacks.length;B<w;B++){J.callbacks[B](E,J.name,r)}}}}return N};if(m.remove_trailing_brs){l.addNodeFilter("br",function(r){var w,v=r.length,s,B=h({},n.getBlockElements());var q=n.getNonEmptyElements(),z,x,u,A;var y,t;B.body=1;for(w=0;w<v;w++){s=r[w];z=s.parent;if(B[s.parent.name]&&s===z.lastChild){u=s.prev;while(u){A=u.name;if(A!=="span"||u.attr("data-mce-type")!=="bookmark"){if(A!=="br"){break}if(A==="br"){s=null;break}}u=u.prev}if(s){s.remove();if(z.isEmpty(q)){y=n.getElementRule(z.name);if(y){if(y.removeEmpty){z.remove()}else{if(y.paddEmpty){z.empty().append(new c("#text",3)).value="\u00a0"}}}}}}else{x=s;while(z&&z.firstChild===x&&z.lastChild===x){x=z;if(B[z.name]){break}z=z.parent}if(x===z){t=new c("#text",3);t.value="\u00a0";s.replace(t)}}}})}if(!m.allow_html_in_named_anchor){l.addAttributeFilter("id,name",function(q){var s=q.length,u,r,t,v;while(s--){v=q[s];if(v.name==="a"&&v.firstChild&&!v.attr("href")){t=v.parent;u=v.lastChild;do{r=u.prev;t.insert(u,v);u=r}while(u)}}})}if(m.validate&&n.getValidClasses()){l.addAttributeFilter("class",function(r){var v=r.length,u,s,z,x,t;var y=n.getValidClasses(),w,q;while(v--){u=r[v];s=u.attr("class").split(" ");t="";for(z=0;z<s.length;z++){x=s[z];q=false;w=y["*"];if(w&&w[x]){q=true}w=y[u.name];if(!q&&w&&w[x]){q=true}if(q){if(t){t+=" "}t+=x}}if(!t.length){t=null}u.attr("class",t)}})}}});