KISSY.Editor.add("htmldataprocessor",function(I){function L(g){return g.replace(M,function(k,d,e){return"<"+d+e.replace(N,function(h,n){if(e.indexOf("_ke_saved_"+n)==-1)return" _ke_saved_"+h+" "+h;return h})+">"})}var A=A,y=KISSY,l=y.Editor,O=y.Node,w=y.UA,F=l.NODE,t=l.HtmlParser,B=new t.Filter,G=new t.Filter,H=new t.Filter,J=l.XHTML_DTD;if(!I.htmlDataProcessor){(function(){var g=l.HtmlParser.Fragment.prototype,k=l.HtmlParser.Element.prototype;g.onlyChild=k.onlyChild=function(){var d=this.children;
return d.length==1&&d[0]||null};k.removeAnyChildWithName=function(d){for(var e=this.children,h=[],n,i=0;i<e.length;i++){n=e[i];if(n.name){if(n.name==d){h.push(n);e.splice(i--,1)}h=h.concat(n.removeAnyChildWithName(d))}}return h};k.getAncestor=function(d){for(var e=this.parent;e&&!(e.name&&e.name.match(d));)e=e.parent;return e};g.firstChild=k.firstChild=function(d){for(var e,h=0;h<this.children.length;h++){e=this.children[h];if(d(e))return e;else if(e.name)if(e=e.firstChild(d))return e}return null};
k.addStyle=function(d,e,h){var n="";if(typeof e=="string")n+=d+":"+e+";";else{if(typeof d=="object")for(var i in d){if(d.hasOwnProperty(i))n+=i+":"+d[i]+";"}else n+=d;h=e}if(!this.attributes)this.attributes={};d=this.attributes.style||"";d=(h?[n,d]:[d,n]).join(";");this.attributes.style=d.replace(/^;|;(?=;)/,"")};J.parentOf=function(d){var e={},h;for(h in this)if(h.indexOf("$")==-1&&this[h][d])e[h]=1;return e}})();(function(){function g(a){if(/mso-list\s*:\s*Ignore/i.test(a.attributes&&a.attributes.style||
""))return true;return A}function k(a,b){var c=new l.HtmlParser.Element("ke:listbullet"),f;if(a)if(a[2]){a=isNaN(a[1])?/^[a-z]+$/.test(a[1])?"lower-alpha":/^[A-Z]+$/.test(a[1])?"upper-alpha":"decimal":"decimal";f="ol"}else{a=/[l\u00B7\u2002]/.test(a[1])?"disc":/[\u006F\u00D8]/.test(a[1])?"circle":/[\u006E\u25C6]/.test(a[1])?"square":"disc";f="ul"}else{a="decimal";f="ol"}c.attributes={"ke:listtype":f,style:"list-style-type:"+a+";"};c.add(new l.HtmlParser.Text(b));return c}function d(a){var b=a.attributes,
c;if((c=a.removeAnyChildWithName("ke:listbullet"))&&c.length&&(c=c[0])){a.name="ke:li";if(b.style)b.style=e([["text-indent"],["line-height"],[/^margin(:?-left)?$/,null,function(f){f=f.split(" ");f=f[3]||f[1]||f[0];f=parseInt(f,10);if(!i&&u&&f>u)i=f-u;b["ke:margin"]=u=f}]],A)(b.style,a)||"";c=c.attributes;a.addStyle(c.style);y.mix(b,c);return true}return false}function e(a,b){return function(c,f){var m=[];String(c).replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(p,o,
r){o=o.toLowerCase();o=="font-family"&&(r=r.replace(/["']/g,""));for(var C,q,K,z=0;z<a.length;z++)if(a[z]){p=a[z][0];C=a[z][1];q=a[z][2];K=a[z][3];if(o.match(p)&&(!C||r.match(C))){o=K||o;b&&(q=q||r);if(typeof q=="function")q=q(r,f,o);if(q&&q.push){o=q[0];q=q[1]}typeof q=="string"&&m.push([o,q]);return}}!b&&m.push([o,r])});for(var v=0;v<m.length;v++)m[v]=m[v].join(":");return m.length?m.join(";")+";":false}}function h(a){a=a.children;for(var b,c,f,m,v,p,o,r=0;r<a.length;r++){b=a[r];if("ke:li"==b.name){b.name=
"li";b=b;c=b.attributes;f=b.attributes["ke:listtype"];m=parseInt(c["ke:indent"],10)||i&&Math.ceil(c["ke:margin"]/i)||1;c.style&&(c.style=e([["list-style-type",f=="ol"?"decimal":"disc"]],A)(c.style)||"");if(p){if(m>o){p=new l.HtmlParser.Element(f);p.add(b);v.add(p)}else{if(m<o){v=o-m;for(var C;v--&&(C=p.parent);)p=C.parent}p.add(b)}a.splice(r--,1)}else{p=new l.HtmlParser.Element(f);p.add(b);a[r]=p}v=b;o=m}else p=null}i=0}var n=e([[/mso/i],[/w:WordDocument/i],[/^-ms/i],[/^-moz/i],[/^-webkit/i],[/line-height/i],
[/display/i,/none/i]],A),i,u=0,x=J.parentOf("ol"),D={elementNames:[[/^script$/i,""],[/^iframe$/i,""],[/^style$/i,""],[/^link$/i,""],[/^meta$/i,""],[/^\?xml.*$/i,""],[/^.*namespace.*$/i,""]],root:function(a){a.filterChildren();h(a)},elements:{p:function(a){a.filterChildren();if(d(a))return A},$:function(a){var b=a.name||"";b.indexOf(":")!=-1&&b.indexOf("ke")==-1&&delete a.name;if(b in x){a.filterChildren();h(a)}},span:function(a){if(!w.gecko&&g(a.parent))return false;if(!w.gecko&&g(a)){a=(a=a.firstChild(function(c){return c.value||
c.name=="img"}))&&(a.value||"l.");var b=a.match(/^([^\s]+?)([.)]?)$/);return k(b,a)}}},attributes:{"class":function(a){if(/(^|\s+)Mso/.test(a))return false;return a},style:function(a){a=n(a);if(!a)return false;return a}},attributeNames:[[/^on/,"ke_on"],[/^lang$/,""]]},j={comment:!w.ie?function(a,b){var c=a.match(/<img.*?>/),f=a.match(/^\[if !supportLists\]([\s\S]*?)\[endif\]$/);if(f){f=(c=f[1]||c&&"l.")&&c.match(/>([^\s]+?)([.)]?)</);return k(f,c)}if(w.gecko&&c){c=l.HtmlParser.Fragment.FromHtml(c[0]).children[0];
(f=(f=(f=b.previous)&&f.value.match(/<v:imagedata[^>]*o:href=['"](.*?)['"]/))&&f[1])&&(c.attributes.src=f);return c}return false}:function(){return false}},s={elementNames:[[/^ke:/,""],[/^\?xml:namespace$/,""]],elements:{$:function(a){var b=a.attributes;if(b)for(var c=["name","href","src"],f,m=0;m<c.length;m++){f="_ke_saved_"+c[m];f in b&&delete b[c[m]]}return a},embed:function(a){var b=a.parent;if(b&&b.name=="object"){var c=b.attributes.width;b=b.attributes.height;c&&(a.attributes.width=c);b&&(a.attributes.height=
b)}},param:function(a){a.children=[];a.isEmpty=true;return a},a:function(a){if(!(a.children.length||a.attributes.name||a.attributes._ke_saved_name))return false},td:function(a){for(var b=a.children,c=0;c<b.length;c++)if(b[c].name=="br"){b.splice(c,1);--c}if(!a.children.length){b=new l.HtmlParser.Text("&nbsp;");a.children.push(b)}},span:function(a){if(!a.children.length&&y.isEmptyObject(a.attributes))return false}},attributes:{style:function(a){if(!y.trim(a))return false}},attributeNames:[[/^_ke_saved_/,
""],[/^ke_on/,"on"],[/^_ke.*/,""],[/^_ks.*/,""],[/^ke:.*$/,""]],comment:function(a){if(a.substr(0,E.length)==E){a=a.substr(E.length,3)=="{C}"?a.substr(E.length+3):a.substr(E.length);return new l.HtmlParser.cdata(decodeURIComponent(a))}return a}};if(w.ie)s.attributes.style=function(a){return a.toLowerCase()};B.addRules(s);G.addRules(D);H.addRules(D);H.addRules(j)})();(function(){function g(j){for(var s=j.children.length,a=j.children[s-1];a&&a.type==F.NODE_TEXT&&!y.trim(a.value);)a=j.children[--s];
return a}function k(j){var s=g(j);return!s||s.type==F.NODE_ELEMENT&&s.name=="br"||j.name=="form"&&s.name=="input"}function d(j,s){var a=j.children,b=g(j);if(b){if((s||!w.ie)&&b.type==F.NODE_ELEMENT&&b.name=="br")a.pop();b.type==F.NODE_TEXT&&n.test(b.value)&&a.pop()}}function e(j){d(j,true);if(k(j))if(w.ie)j.add(new l.HtmlParser.Text("\u00a0"));else{j.add(new l.HtmlParser.Text("&nbsp;"));j.add(new l.HtmlParser.Element("br",{}))}}function h(j){d(j,false);k(j)&&j.add(new l.HtmlParser.Text("\u00a0"))}var n=/^[\t\r\n ]*(?:&nbsp;|\xa0)$/,
i=l.XHTML_DTD,u=l.Utils.mix({},i.$block,i.$listItem,i.$tableContent),x;for(x in u)"br"in i[x]||delete u[x];delete u.pre;i={elements:{}};var D={elements:{}};for(x in u){i.elements[x]=e;D.elements[x]=h}G.addRules(i);B.addRules(D);H.addRules(i)})();(function(){B.addRules({text:function(g){return g.replace(/\xa0/g,"&nbsp;")}})})();var M=/<(a|area|img|input)\b([^>]*)>/gi,N=/\b(href|src|name)\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|(?:[^ "'>]+))/gi,E="{ke_protected}";I.htmlDataProcessor={wordFilter:H,dataFilter:G,
htmlFilter:B,toHtml:function(g,k){var d=new t.HtmlWriter;t.Fragment.FromHtml(g,k).writeHtml(d,B);return d.getHtml(true)},toDataFormat:function(g,k,d){d=d||G;if(w.gecko)g=g.replace(/(<!--\[if[^<]*?\])--\>([\S\s]*?)<!--(\[endif\]--\>)/gi,"$1$2$3");g=L(g);var e=new O("<div>");e.html("a"+g);g=e.html().substr(1);e=new t.BasicWriter;g=t.Fragment.FromHtml(g,k);e.reset();g.writeHtml(e,d);return g=e.getHtml(true)},toServer:function(g,k){var d=new t.BasicWriter;t.Fragment.FromHtml(g,k).writeHtml(d,B);return d.getHtml(true)}}}},
{attach:false});
