JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-4.0_full
[ckeditor.git] / plugins / pastefromword / filter / default.js
index 55a9709..12d01b5 100644 (file)
@@ -1,10 +1,30 @@
-/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
-For licensing, see LICENSE.html or http://ckeditor.com/license\r
-*/\r
-\r
-(function(){var a=CKEDITOR.htmlParser.fragment.prototype,b=CKEDITOR.htmlParser.element.prototype;a.onlyChild=b.onlyChild=function(){var h=this.children,i=h.length,j=i==1&&h[0];return j||null;};b.removeAnyChildWithName=function(h){var i=this.children,j=[],k;for(var l=0;l<i.length;l++){k=i[l];if(!k.name)continue;if(k.name==h){j.push(k);i.splice(l--,1);}j=j.concat(k.removeAnyChildWithName(h));}return j;};b.getAncestor=function(h){var i=this.parent;while(i&&!(i.name&&i.name.match(h)))i=i.parent;return i;};a.firstChild=b.firstChild=function(h){var i;for(var j=0;j<this.children.length;j++){i=this.children[j];if(h(i))return i;else if(i.name){i=i.firstChild(h);if(i)return i;else continue;}}return null;};b.addStyle=function(h,i,j){var n=this;var k,l='';if(typeof i=='string')l+=h+':'+i+';';else{if(typeof h=='object')for(var m in h){if(h.hasOwnProperty(m))l+=m+':'+h[m]+';';}else l+=h;j=i;}if(!n.attributes)n.attributes={};k=n.attributes.style||'';k=(j?[l,k]:[k,l]).join(';');n.attributes.style=k.replace(/^;|;(?=;)/,'');};CKEDITOR.dtd.parentOf=function(h){var i={};for(var j in this){if(j.indexOf('$')==-1&&this[j][h])i[j]=1;}return i;};var c=/^(\d[.\d]*)+(em|ex|px|gd|rem|vw|vh|vm|ch|mm|cm|in|pt|pc|deg|rad|ms|s|hz|khz){1}?/i,d=/^(?:\b0[^\s]*\s*){1,4}$/,e=0,f;CKEDITOR.plugins.pastefromword={utils:{createListBulletMarker:function(h,i){var j=new CKEDITOR.htmlParser.element('cke:listbullet'),k;if(!h){h='decimal';k='ol';}else if(h[2]){if(!isNaN(h[1]))h='decimal';else if(/^[a-z]+$/.test(h[1]))h='lower-alpha';else if(/^[A-Z]+$/.test(h[1]))h='upper-alpha';else h='decimal';k='ol';}else{if(/[l\u00B7\u2002]/.test(h[1]))h='disc';else if(/[\u006F\u00D8]/.test(h[1]))h='circle';else if(/[\u006E\u25C6]/.test(h[1]))h='square';else h='disc';k='ul';}j.attributes={'cke:listtype':k,style:'list-style-type:'+h+';'};j.add(new CKEDITOR.htmlParser.text(i));return j;},isListBulletIndicator:function(h){var i=h.attributes&&h.attributes.style;if(/mso-list\s*:\s*Ignore/i.test(i))return true;},isContainingOnlySpaces:function(h){var i;return(i=h.onlyChild())&&/^(:?\s|&nbsp;)+$/.test(i.value);},resolveList:function(h){var i=h.children,j=h.attributes,k;if((k=h.removeAnyChildWithName('cke:listbullet'))&&k.length&&(k=k[0])){h.name='cke:li';if(j.style)j.style=CKEDITOR.plugins.pastefromword.filters.stylesFilter([['text-indent'],['line-height'],[/^margin(:?-left)?$/,null,function(n){var o=n.split(' ');n=o[3]||o[1]||o[0];n=parseInt(n,10);if(!e&&f&&n>f)e=n-f;j['cke:margin']=f=n;}]])(j.style,h)||'';var l=k.attributes,m=l.style;\r
-h.addStyle(m);CKEDITOR.tools.extend(j,l);return true;}return false;},convertToPx:(function(){var h=CKEDITOR.dom.element.createFromHtml('<div style="position:absolute;left:-9999px;top:-9999px;margin:0px;padding:0px;border:0px;"></div>',CKEDITOR.document);CKEDITOR.document.getBody().append(h);return function(i){if(c.test(i)){h.setStyle('width',i);return h.$.clientWidth+'px';}return i;};})(),getStyleComponents:(function(){var h=CKEDITOR.dom.element.createFromHtml('<div style="position:absolute;left:-9999px;top:-9999px;"></div>',CKEDITOR.document);CKEDITOR.document.getBody().append(h);return function(i,j,k){h.setStyle(i,j);var l={},m=k.length;for(var n=0;n<m;n++)l[k[n]]=h.getStyle(k[n]);return l;};})(),listDtdParents:CKEDITOR.dtd.parentOf('ol')},filters:{flattenList:function(h){var i=h.attributes,j=h.parent,k,l=1;while(j){j.attributes&&j.attributes['cke:list']&&l++;j=j.parent;}switch(i.type){case 'a':k='lower-alpha';break;}var m=h.children,n;for(var o=0;o<m.length;o++){n=m[o];var p=n.attributes;if(n.name in CKEDITOR.dtd.$listItem){var q=n.children,r=q.length,s=q[r-1];if(s.name in CKEDITOR.dtd.$list){m.splice(o+1,0,s);s.parent=h;if(!--q.length)m.splice(o,1);}n.name='cke:li';p['cke:indent']=l;f=0;p['cke:listtype']=h.name;k&&n.addStyle('list-style-type',k,true);}}delete h.name;i['cke:list']=1;},assembleList:function(h){var i=h.children,j,k,l,m,n,o,p,q,r;for(var s=0;s<i.length;s++){j=i[s];if('cke:li'==j.name){j.name='li';k=j;l=k.attributes;m=k.attributes['cke:listtype'];n=parseInt(l['cke:indent'],10)||e&&Math.ceil(l['cke:margin']/e)||1;l.style&&(l.style=CKEDITOR.plugins.pastefromword.filters.stylesFilter([['list-style-type',m=='ol'?'decimal':'disc']])(l.style)||'');if(!p){p=new CKEDITOR.htmlParser.element(m);p.add(k);i[s]=p;}else{if(n>r){p=new CKEDITOR.htmlParser.element(m);p.add(k);o.add(p);}else if(n<r){var t=r-n,u;while(t--&&(u=p.parent))p=u.parent;p.add(k);}else p.add(k);i.splice(s--,1);}o=k;r=n;}else p=null;}e=0;},falsyFilter:function(h){return false;},stylesFilter:function(h,i){return function(j,k){var l=[];j.replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(n,o,p){o=o.toLowerCase();o=='font-family'&&(p=p.replace(/["']/g,''));var q,r,s,t;for(var u=0;u<h.length;u++){if(h[u]){q=h[u][0];r=h[u][1];s=h[u][2];t=h[u][3];if(o.match(q)&&(!r||p.match(r))){o=t||o;i&&(s=s||p);if(typeof s=='function')s=s(p,k,o);if(s&&s.push)o=s[0],s=s[1];if(typeof s=='string')l.push([o,s]);return;}}}!i&&l.push([o,p]);});for(var m=0;m<l.length;m++)l[m]=l[m].join(':');\r
-return l.length?l.join(';')+';':false;};},elementMigrateFilter:function(h,i){return function(j){var k=i?new CKEDITOR.style(h,i)._.definition:h;j.name=k.element;CKEDITOR.tools.extend(j.attributes,CKEDITOR.tools.clone(k.attributes));j.addStyle(CKEDITOR.style.getStyleText(k));};},styleMigrateFilter:function(h,i){var j=this.elementMigrateFilter;return function(k,l){var m=new CKEDITOR.htmlParser.element(null),n={};n[i]=k;j(h,n)(m);m.children=l.children;l.children=[m];};},bogusAttrFilter:function(h,i){if(i.name.indexOf('cke:')==-1)return false;},applyStyleFilter:null},getRules:function(h){var i=CKEDITOR.dtd,j=CKEDITOR.tools.extend({},i.$block,i.$listItem,i.$tableContent),k=h.config,l=this.filters,m=l.falsyFilter,n=l.stylesFilter,o=l.elementMigrateFilter,p=CKEDITOR.tools.bind(this.filters.styleMigrateFilter,this.filters),q=l.bogusAttrFilter,r=this.utils.createListBulletMarker,s=l.flattenList,t=l.assembleList,u=this.utils.isListBulletIndicator,v=this.utils.isContainingOnlySpaces,w=this.utils.resolveList,x=this.utils.convertToPx,y=this.utils.getStyleComponents,z=this.utils.listDtdParents,A=k.pasteFromWordRemoveFontStyles!==false,B=k.pasteFromWordRemoveStyles!==false;return{elementNames:[[/meta|link|script/,'']],root:function(C){C.filterChildren();t(C);},elements:{'^':function(C){var D;if(CKEDITOR.env.gecko&&(D=l.applyStyleFilter))D(C);},$:function(C){var D=C.name||'',E=C.attributes;if(D in j&&E.style)E.style=n([[/^(:?width|height)$/,null,x]])(E.style)||'';if(D.match(/h\d/)){C.filterChildren();if(w(C))return;o(k['format_'+D])(C);}else if(D in i.$inline){C.filterChildren();if(v(C))delete C.name;}else if(D.indexOf(':')!=-1&&D.indexOf('cke')==-1){C.filterChildren();if(D=='v:imagedata'){var F=C.attributes['o:href'];if(F)C.attributes.src=F;C.name='img';return;}delete C.name;}if(D in z){C.filterChildren();t(C);}},style:function(C){if(CKEDITOR.env.gecko){var D=C.onlyChild().value.match(/\/\* Style Definitions \*\/([\s\S]*?)\/\*/),E=D&&D[1],F={};if(E){E.replace(/[\n\r]/g,'').replace(/(.+?)\{(.+?)\}/g,function(G,H,I){H=H.split(',');var J=H.length,K;for(var L=0;L<J;L++)CKEDITOR.tools.trim(H[L]).replace(/^(\w+)(\.[\w-]+)?$/g,function(M,N,O){N=N||'*';O=O.substring(1,O.length);if(O.match(/MsoNormal/))return;if(!F[N])F[N]={};if(O)F[N][O]=I;else F[N]=I;});});l.applyStyleFilter=function(G){var H=F['*']?'*':G.name,I=G.attributes&&G.attributes['class'],J;if(H in F){J=F[H];if(typeof J=='object')J=J[I];J&&G.addStyle(J,true);}};}}return false;},p:function(C){C.filterChildren();var D=C.attributes,E=C.parent,F=C.children;\r
-if(w(C))return;if(k.enterMode==CKEDITOR.ENTER_BR){delete C.name;C.add(new CKEDITOR.htmlParser.element('br'));}else o(k['format_'+(k.enterMode==CKEDITOR.ENTER_P?'p':'div')])(C);},div:function(C){var D=C.onlyChild();if(D&&D.name=='table'){var E=C.attributes;D.attributes=CKEDITOR.tools.extend(D.attributes,E);E.style&&D.addStyle(E.style);var F=new CKEDITOR.htmlParser.element('div');F.addStyle('clear','both');C.add(F);delete C.name;}},td:function(C){if(C.getAncestor('thead'))C.name='th';},ol:s,ul:s,dl:s,font:function(C){if(!CKEDITOR.env.gecko&&u(C.parent)){delete C.name;return;}C.filterChildren();var D=C.attributes,E=D.style,F=C.parent;if('font'==F.name){CKEDITOR.tools.extend(F.attributes,C.attributes);E&&F.addStyle(E);delete C.name;return;}else{E=E||'';if(D.color){D.color!='#000000'&&(E+='color:'+D.color+';');delete D.color;}if(D.face){E+='font-family:'+D.face+';';delete D.face;}if(D.size){E+='font-size:'+(D.size>3?'large':D.size<3?'small':'medium')+';';delete D.size;}C.name='span';C.addStyle(E);}},span:function(C){if(!CKEDITOR.env.gecko&&u(C.parent))return false;C.filterChildren();if(v(C)){delete C.name;return null;}if(!CKEDITOR.env.gecko&&u(C)){var D=C.firstChild(function(K){return K.value||K.name=='img';}),E=D&&(D.value||'l.'),F=E.match(/^([^\s]+?)([.)]?)$/);return r(F,E);}var G=C.children,H=C.attributes,I=H&&H.style,J=G&&G[0];if(I)H.style=n([['line-height'],[/^font-family$/,null,!A?p(k.font_style,'family'):null],[/^font-size$/,null,!A?p(k.fontSize_style,'size'):null],[/^color$/,null,!A?p(k.colorButton_foreStyle,'color'):null],[/^background-color$/,null,!A?p(k.colorButton_backStyle,'color'):null]])(I,C)||'';return null;},b:o(k.coreStyles_bold),i:o(k.coreStyles_italic),u:o(k.coreStyles_underline),s:o(k.coreStyles_strike),sup:o(k.coreStyles_superscript),sub:o(k.coreStyles_subscript),a:function(C){var D=C.attributes;if(D&&!D.href&&D.name)delete C.name;},'cke:listbullet':function(C){if(C.getAncestor(/h\d/)&&!k.pasteFromWordNumberedHeadingToList)delete C.name;}},attributeNames:[[/^onmouse(:?out|over)/,''],[/^onload$/,''],[/(?:v|o):\w+/,''],[/^lang/,'']],attributes:{style:n(B?[[/^margin$|^margin-(?!bottom|top)/,null,function(C,D,E){if(D.name in {p:1,div:1}){var F=k.contentsLangDirection=='ltr'?'margin-left':'margin-right';if(E=='margin')C=y(E,C,[F])[F];else if(E!=F)return null;if(C&&!d.test(C))return[F,C];}return null;}],[/^clear$/],[/^border.*|margin.*|vertical-align|float$/,null,function(C,D){if(D.name=='img')return C;}],[/^width|height$/,null,function(C,D){if(D.name in {table:1,td:1,th:1,img:1})return C;\r
-}]]:[[/^mso-/],[/-color$/,null,function(C){if(C=='transparent')return false;if(CKEDITOR.env.gecko)return C.replace(/-moz-use-text-color/g,'transparent');}],[/^margin$/,d],['text-indent','0cm'],['page-break-before'],['tab-stops'],['display','none'],A?[/font-?/]:null],B),width:function(C,D){if(D.name in i.$tableContent)return false;},border:function(C,D){if(D.name in i.$tableContent)return false;},'class':m,bgcolor:m,valign:B?m:function(C,D){D.addStyle('vertical-align',C);return false;}},comment:!CKEDITOR.env.ie?function(C,D){var E=C.match(/<img.*?>/),F=C.match(/^\[if !supportLists\]([\s\S]*?)\[endif\]$/);if(F){var G=F[1]||E&&'l.',H=G&&G.match(/>([^\s]+?)([.)]?)</);return r(H,G);}if(CKEDITOR.env.gecko&&E){var I=CKEDITOR.htmlParser.fragment.fromHtml(E[0]).children[0],J=D.previous,K=J&&J.value.match(/<v:imagedata[^>]*o:href=['"](.*?)['"]/),L=K&&K[1];L&&(I.attributes.src=L);return I;}return false;}:m};}};var g=function(){this.dataFilter=new CKEDITOR.htmlParser.filter();};g.prototype={toHtml:function(h){var i=CKEDITOR.htmlParser.fragment.fromHtml(h,false),j=new CKEDITOR.htmlParser.basicWriter();i.writeHtml(j,this.dataFilter);return j.getHtml(true);}};CKEDITOR.cleanWord=function(h,i){if(CKEDITOR.env.gecko)h=h.replace(/(<!--\[if[^<]*?\])-->([\S\s]*?)<!--(\[endif\]-->)/gi,'$1$2$3');var j=new g(),k=j.dataFilter;k.addRules(CKEDITOR.plugins.pastefromword.getRules(i));i.fire('beforeCleanWord',{filter:k});try{h=j.toHtml(h,false);}catch(l){alert(i.lang.pastefromword.error);}h=h.replace(/cke:.*?".*?"/g,'');h=h.replace(/style=""/g,'');h=h.replace(/<span>/g,'');return h;};})();\r
+/*
+ Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
+ For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+(function(){function y(a){for(var a=a.toUpperCase(),b=z.length,d=0,c=0;c<b;++c)for(var e=z[c],f=e[1].length;a.substr(0,f)==e[1];a=a.substr(f))d+=e[0];return d}function A(a){for(var a=a.toUpperCase(),b=B.length,d=1,c=1;0<a.length;c*=b)d+=B.indexOf(a.charAt(a.length-1))*c,a=a.substr(0,a.length-1);return d}var C=CKEDITOR.htmlParser.fragment.prototype,w=CKEDITOR.htmlParser.element.prototype;C.onlyChild=w.onlyChild=function(){var a=this.children;return 1==a.length&&a[0]||null};w.removeAnyChildWithName=
+function(a){for(var b=this.children,d=[],c,e=0;e<b.length;e++)c=b[e],c.name&&(c.name==a&&(d.push(c),b.splice(e--,1)),d=d.concat(c.removeAnyChildWithName(a)));return d};w.getAncestor=function(a){for(var b=this.parent;b&&(!b.name||!b.name.match(a));)b=b.parent;return b};C.firstChild=w.firstChild=function(a){for(var b,d=0;d<this.children.length;d++)if(b=this.children[d],a(b)||b.name&&(b=b.firstChild(a)))return b;return null};w.addStyle=function(a,b,d){var c="";if("string"==typeof b)c+=a+":"+b+";";else{if("object"==
+typeof a)for(var e in a)a.hasOwnProperty(e)&&(c+=e+":"+a[e]+";");else c+=a;d=b}this.attributes||(this.attributes={});a=this.attributes.style||"";a=(d?[c,a]:[a,c]).join(";");this.attributes.style=a.replace(/^;|;(?=;)/,"")};CKEDITOR.dtd.parentOf=function(a){var b={},d;for(d in this)-1==d.indexOf("$")&&this[d][a]&&(b[d]=1);return b};var G=/^([.\d]*)+(em|ex|px|gd|rem|vw|vh|vm|ch|mm|cm|in|pt|pc|deg|rad|ms|s|hz|khz){1}?/i,D=/^(?:\b0[^\s]*\s*){1,4}$/,x={ol:{decimal:/\d+/,"lower-roman":/^m{0,4}(cm|cd|d?c{0,3})(xc|xl|l?x{0,3})(ix|iv|v?i{0,3})$/,
+"upper-roman":/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"lower-alpha":/^[a-z]+$/,"upper-alpha":/^[A-Z]+$/},ul:{disc:/[l\u00B7\u2002]/,circle:/[\u006F\u00D8]/,square:/[\u006E\u25C6]/}},z=[[1E3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]],B="ABCDEFGHIJKLMNOPQRSTUVWXYZ",u=0,p=null,v,E=CKEDITOR.plugins.pastefromword={utils:{createListBulletMarker:function(a,b){var d=new CKEDITOR.htmlParser.element("cke:listbullet");
+d.attributes={"cke:listsymbol":a[0]};d.add(new CKEDITOR.htmlParser.text(b));return d},isListBulletIndicator:function(a){if(/mso-list\s*:\s*Ignore/i.test(a.attributes&&a.attributes.style))return!0},isContainingOnlySpaces:function(a){var b;return(b=a.onlyChild())&&/^(:?\s|&nbsp;)+$/.test(b.value)},resolveList:function(a){var b=a.attributes,d;if((d=a.removeAnyChildWithName("cke:listbullet"))&&d.length&&(d=d[0]))return a.name="cke:li",b.style&&(b.style=E.filters.stylesFilter([["text-indent"],["line-height"],
+[/^margin(:?-left)?$/,null,function(a){a=a.split(" ");a=CKEDITOR.tools.convertToPx(a[3]||a[1]||a[0]);!u&&(null!==p&&a>p)&&(u=a-p);p=a;b["cke:indent"]=u&&Math.ceil(a/u)+1||1}],[/^mso-list$/,null,function(a){var a=a.split(" "),d=Number(a[0].match(/\d+/)),a=Number(a[1].match(/\d+/));1==a&&(d!==v&&(b["cke:reset"]=1),v=d);b["cke:indent"]=a}]])(b.style,a)||""),b["cke:indent"]||(p=0,b["cke:indent"]=1),CKEDITOR.tools.extend(b,d.attributes),!0;v=p=u=null;return!1},getStyleComponents:function(){var a=CKEDITOR.dom.element.createFromHtml('<div style="position:absolute;left:-9999px;top:-9999px;"></div>',
+CKEDITOR.document);CKEDITOR.document.getBody().append(a);return function(b,d,c){a.setStyle(b,d);for(var b={},d=c.length,e=0;e<d;e++)b[c[e]]=a.getStyle(c[e]);return b}}(),listDtdParents:CKEDITOR.dtd.parentOf("ol")},filters:{flattenList:function(a,b){var b="number"==typeof b?b:1,d=a.attributes,c;switch(d.type){case "a":c="lower-alpha";break;case "1":c="decimal"}for(var e=a.children,f,h=0;h<e.length;h++)if(f=e[h],f.name in CKEDITOR.dtd.$listItem){var g=f.attributes,i=f.children,n=i[i.length-1];n.name in
+CKEDITOR.dtd.$list&&(a.add(n,h+1),--i.length||e.splice(h--,1));f.name="cke:li";d.start&&!h&&(g.value=d.start);E.filters.stylesFilter([["tab-stops",null,function(a){(a=a.split(" ")[1].match(G))&&(p=CKEDITOR.tools.convertToPx(a[0]))}],1==b?["mso-list",null,function(a){a=a.split(" ");a=Number(a[0].match(/\d+/));a!==v&&(g["cke:reset"]=1);v=a}]:null])(g.style);g["cke:indent"]=b;g["cke:listtype"]=a.name;g["cke:list-style-type"]=c}else if(f.name in CKEDITOR.dtd.$list){arguments.callee.apply(this,[f,b+1]);
+e=e.slice(0,h).concat(f.children).concat(e.slice(h+1));a.children=[];f=0;for(i=e.length;f<i;f++)a.add(e[f])}delete a.name;d["cke:list"]=1},assembleList:function(a){for(var b=a.children,d,c,e,f,h,g,a=[],i,n,j,m,k,r,q=0;q<b.length;q++)if(d=b[q],"cke:li"==d.name)if(d.name="li",c=d.attributes,j=(j=c["cke:listsymbol"])&&j.match(/^(?:[(]?)([^\s]+?)([.)]?)$/),m=k=r=null,c["cke:ignored"])b.splice(q--,1);else{c["cke:reset"]&&(g=f=h=null);e=Number(c["cke:indent"]);e!=f&&(n=i=null);if(j){if(n&&x[n][i].test(j[1]))m=
+n,k=i;else for(var s in x)for(var t in x[s])if(x[s][t].test(j[1]))if("ol"==s&&/alpha|roman/.test(t)){if(i=/roman/.test(t)?y(j[1]):A(j[1]),!r||i<r)r=i,m=s,k=t}else{m=s;k=t;break}!m&&(m=j[2]?"ol":"ul")}else m=c["cke:listtype"]||"ol",k=c["cke:list-style-type"];n=m;i=k||("ol"==m?"decimal":"disc");k&&k!=("ol"==m?"decimal":"disc")&&d.addStyle("list-style-type",k);if("ol"==m&&j){switch(k){case "decimal":r=Number(j[1]);break;case "lower-roman":case "upper-roman":r=y(j[1]);break;case "lower-alpha":case "upper-alpha":r=
+A(j[1])}d.attributes.value=r}if(g){if(e>f)a.push(g=new CKEDITOR.htmlParser.element(m)),g.add(d),h.add(g);else{if(e<f){f-=e;for(var o;f--&&(o=g.parent);)g=o.parent}g.add(d)}b.splice(q--,1)}else a.push(g=new CKEDITOR.htmlParser.element(m)),g.add(d),b[q]=g;h=d;f=e}else g&&(g=f=h=null);for(q=0;q<a.length;q++)if(g=a[q],s=g.children,i=i=void 0,t=g.children.length,o=i=void 0,b=/list-style-type:(.*?)(?:;|$)/,f=CKEDITOR.plugins.pastefromword.filters.stylesFilter,i=g.attributes,!b.exec(i.style)){for(h=0;h<
+t;h++)if(i=s[h],i.attributes.value&&Number(i.attributes.value)==h+1&&delete i.attributes.value,i=b.exec(i.attributes.style))if(i[1]==o||!o)o=i[1];else{o=null;break}if(o){for(h=0;h<t;h++)i=s[h].attributes,i.style&&(i.style=f([["list-style-type"]])(i.style)||"");g.addStyle("list-style-type",o)}}v=p=u=null},falsyFilter:function(){return!1},stylesFilter:function(a,b){return function(d,c){var e=[];(d||"").replace(/&quot;/g,'"').replace(/\s*([^ :;]+)\s*:\s*([^;]+)\s*(?=;|$)/g,function(d,g,f){g=g.toLowerCase();
+"font-family"==g&&(f=f.replace(/["']/g,""));for(var n,j,m,k=0;k<a.length;k++)if(a[k]&&(d=a[k][0],n=a[k][1],j=a[k][2],m=a[k][3],g.match(d)&&(!n||f.match(n)))){g=m||g;b&&(j=j||f);"function"==typeof j&&(j=j(f,c,g));j&&j.push&&(g=j[0],j=j[1]);"string"==typeof j&&e.push([g,j]);return}!b&&e.push([g,f])});for(var f=0;f<e.length;f++)e[f]=e[f].join(":");return e.length?e.join(";")+";":!1}},elementMigrateFilter:function(a,b){return function(d){var c=b?(new CKEDITOR.style(a,b))._.definition:a;d.name=c.element;
+CKEDITOR.tools.extend(d.attributes,CKEDITOR.tools.clone(c.attributes));d.addStyle(CKEDITOR.style.getStyleText(c))}},styleMigrateFilter:function(a,b){var d=this.elementMigrateFilter;return function(c,e){var f=new CKEDITOR.htmlParser.element(null),h={};h[b]=c;d(a,h)(f);f.children=e.children;e.children=[f]}},bogusAttrFilter:function(a,b){if(-1==b.name.indexOf("cke:"))return!1},applyStyleFilter:null},getRules:function(a){var b=CKEDITOR.dtd,d=CKEDITOR.tools.extend({},b.$block,b.$listItem,b.$tableContent),
+c=a.config,e=this.filters,a=e.falsyFilter,f=e.stylesFilter,h=e.elementMigrateFilter,g=CKEDITOR.tools.bind(this.filters.styleMigrateFilter,this.filters),i=this.utils.createListBulletMarker,n=e.flattenList,j=e.assembleList,m=this.utils.isListBulletIndicator,k=this.utils.isContainingOnlySpaces,r=this.utils.resolveList,q=function(a){a=CKEDITOR.tools.convertToPx(a);return isNaN(a)?a:a+"px"},s=this.utils.getStyleComponents,t=this.utils.listDtdParents,o=!1!==c.pasteFromWordRemoveFontStyles,p=!1!==c.pasteFromWordRemoveStyles;
+return{elementNames:[[/meta|link|script/,""]],root:function(a){a.filterChildren();j(a)},elements:{"^":function(a){var l;CKEDITOR.env.gecko&&(l=e.applyStyleFilter)&&l(a)},$:function(a){var l=a.name||"",e=a.attributes;l in d&&e.style&&(e.style=f([[/^(:?width|height)$/,null,q]])(e.style)||"");if(l.match(/h\d/)){a.filterChildren();if(r(a))return;h(c["format_"+l])(a)}else if(l in b.$inline)a.filterChildren(),k(a)&&delete a.name;else if(-1!=l.indexOf(":")&&-1==l.indexOf("cke")){a.filterChildren();if("v:imagedata"==
+l){if(l=a.attributes["o:href"])a.attributes.src=l;a.name="img";return}delete a.name}l in t&&(a.filterChildren(),j(a))},style:function(a){if(CKEDITOR.env.gecko){var a=(a=a.onlyChild().value.match(/\/\* Style Definitions \*\/([\s\S]*?)\/\*/))&&a[1],l={};a&&(a.replace(/[\n\r]/g,"").replace(/(.+?)\{(.+?)\}/g,function(a,b,d){for(var b=b.split(","),a=b.length,c=0;c<a;c++)CKEDITOR.tools.trim(b[c]).replace(/^(\w+)(\.[\w-]+)?$/g,function(a,b,c){b=b||"*";c=c.substring(1,c.length);c.match(/MsoNormal/)||(l[b]||
+(l[b]={}),c?l[b][c]=d:l[b]=d)})}),e.applyStyleFilter=function(a){var b=l["*"]?"*":a.name,c=a.attributes&&a.attributes["class"];b in l&&(b=l[b],"object"==typeof b&&(b=b[c]),b&&a.addStyle(b,!0))})}return!1},p:function(a){if(/MsoListParagraph/.exec(a.attributes["class"])){var b=a.firstChild(function(a){return a.type==CKEDITOR.NODE_TEXT&&!k(a.parent)});(b=(b=b&&b.parent)&&b.attributes)&&!b.style&&(b.style="mso-list: Ignore;")}a.filterChildren();r(a)||(c.enterMode==CKEDITOR.ENTER_BR?(delete a.name,a.add(new CKEDITOR.htmlParser.element("br"))):
+h(c["format_"+(c.enterMode==CKEDITOR.ENTER_P?"p":"div")])(a))},div:function(a){var b=a.onlyChild();if(b&&"table"==b.name){var c=a.attributes;b.attributes=CKEDITOR.tools.extend(b.attributes,c);c.style&&b.addStyle(c.style);b=new CKEDITOR.htmlParser.element("div");b.addStyle("clear","both");a.add(b);delete a.name}},td:function(a){a.getAncestor("thead")&&(a.name="th")},ol:n,ul:n,dl:n,font:function(a){if(m(a.parent))delete a.name;else{a.filterChildren();var b=a.attributes,c=b.style,d=a.parent;"font"==
+d.name?(CKEDITOR.tools.extend(d.attributes,a.attributes),c&&d.addStyle(c),delete a.name):(c=c||"",b.color&&("#000000"!=b.color&&(c+="color:"+b.color+";"),delete b.color),b.face&&(c+="font-family:"+b.face+";",delete b.face),b.size&&(c+="font-size:"+(3<b.size?"large":3>b.size?"small":"medium")+";",delete b.size),a.name="span",a.addStyle(c))}},span:function(a){if(m(a.parent))return!1;a.filterChildren();if(k(a))return delete a.name,null;if(m(a)){var b=a.firstChild(function(a){return a.value||"img"==a.name}),
+d=(b=b&&(b.value||"l."))&&b.match(/^(?:[(]?)([^\s]+?)([.)]?)$/);if(d)return b=i(d,b),(a=a.getAncestor("span"))&&/ mso-hide:\s*all|display:\s*none /.test(a.attributes.style)&&(b.attributes["cke:ignored"]=1),b}if(d=(b=a.attributes)&&b.style)b.style=f([["line-height"],[/^font-family$/,null,!o?g(c.font_style,"family"):null],[/^font-size$/,null,!o?g(c.fontSize_style,"size"):null],[/^color$/,null,!o?g(c.colorButton_foreStyle,"color"):null],[/^background-color$/,null,!o?g(c.colorButton_backStyle,"color"):
+null]])(d,a)||"";return null},b:h(c.coreStyles_bold),i:h(c.coreStyles_italic),u:h(c.coreStyles_underline),s:h(c.coreStyles_strike),sup:h(c.coreStyles_superscript),sub:h(c.coreStyles_subscript),a:function(a){var b=a.attributes;b&&!b.href&&b.name?delete a.name:CKEDITOR.env.webkit&&(b.href&&b.href.match(/file:\/\/\/[\S]+#/i))&&(b.href=b.href.replace(/file:\/\/\/[^#]+/i,""))},"cke:listbullet":function(a){a.getAncestor(/h\d/)&&!c.pasteFromWordNumberedHeadingToList&&delete a.name}},attributeNames:[[/^onmouse(:?out|over)/,
+""],[/^onload$/,""],[/(?:v|o):\w+/,""],[/^lang/,""]],attributes:{style:f(p?[[/^list-style-type$/,null],[/^margin$|^margin-(?!bottom|top)/,null,function(a,b,d){if(b.name in{p:1,div:1}){b="ltr"==c.contentsLangDirection?"margin-left":"margin-right";if("margin"==d)a=s(d,a,[b])[b];else if(d!=b)return null;if(a&&!D.test(a))return[b,a]}return null}],[/^clear$/],[/^border.*|margin.*|vertical-align|float$/,null,function(a,b){if("img"==b.name)return a}],[/^width|height$/,null,function(a,b){if(b.name in{table:1,
+td:1,th:1,img:1})return a}]]:[[/^mso-/],[/-color$/,null,function(a){if("transparent"==a)return!1;if(CKEDITOR.env.gecko)return a.replace(/-moz-use-text-color/g,"transparent")}],[/^margin$/,D],["text-indent","0cm"],["page-break-before"],["tab-stops"],["display","none"],o?[/font-?/]:null],p),width:function(a,c){if(c.name in b.$tableContent)return!1},border:function(a,c){if(c.name in b.$tableContent)return!1},"class":a,bgcolor:a,valign:p?a:function(a,b){b.addStyle("vertical-align",a);return!1}},comment:!CKEDITOR.env.ie?
+function(a,b){var c=a.match(/<img.*?>/),d=a.match(/^\[if !supportLists\]([\s\S]*?)\[endif\]$/);return d?(d=(c=d[1]||c&&"l.")&&c.match(/>(?:[(]?)([^\s]+?)([.)]?)</),i(d,c)):CKEDITOR.env.gecko&&c?(c=CKEDITOR.htmlParser.fragment.fromHtml(c[0]).children[0],(d=(d=(d=b.previous)&&d.value.match(/<v:imagedata[^>]*o:href=['"](.*?)['"]/))&&d[1])&&(c.attributes.src=d),c):!1}:a}}},F=function(){this.dataFilter=new CKEDITOR.htmlParser.filter};F.prototype={toHtml:function(a){var a=CKEDITOR.htmlParser.fragment.fromHtml(a),
+b=new CKEDITOR.htmlParser.basicWriter;a.writeHtml(b,this.dataFilter);return b.getHtml(!0)}};CKEDITOR.cleanWord=function(a,b){CKEDITOR.env.gecko&&(a=a.replace(/(<\!--\[if[^<]*?\])--\>([\S\s]*?)<\!--(\[endif\]--\>)/gi,"$1$2$3"));var d=new F,c=d.dataFilter;c.addRules(CKEDITOR.plugins.pastefromword.getRules(b));b.fire("beforeCleanWord",{filter:c});try{a=d.toHtml(a)}catch(e){alert(b.lang.pastefromword.error)}a=a.replace(/cke:.*?".*?"/g,"");a=a.replace(/style=""/g,"");return a=a.replace(/<span>/g,"")}})();
\ No newline at end of file