(function($){UMEDITOR_CONFIG=window.UMEDITOR_CONFIG||{};window.UM={list:{},plugins:{},commands:{},I18N:{},version:"1.2.2"};var dom=UM.dom={};var browser=UM.browser=function(){var agent=navigator.userAgent.toLowerCase(),opera=window.opera,browser={ie:/(msie\s|trident.*rv:)([\w.]+)/.test(agent),opera:!!opera&&opera.version,webkit:agent.indexOf(" applewebkit/")>-1,mac:agent.indexOf("macintosh")>-1,quirks:document.compatMode=="BackCompat"};browser.gecko=navigator.product=="Gecko"&&!browser.webkit&&!browser.opera&&!browser.ie;var version=0;if(browser.ie){var v1=agent.match(/(?:msie\s([\w.]+))/);var v2=agent.match(/(?:trident.*rv:([\w.]+))/);if(v1&&v2&&v1[1]&&v2[1]){version=Math.max(v1[1]*1,v2[1]*1)}else if(v1&&v1[1]){version=v1[1]*1}else if(v2&&v2[1]){version=v2[1]*1}else{version=0}browser.ie11Compat=document.documentMode==11;browser.ie9Compat=document.documentMode==9;browser.ie8=!!document.documentMode;browser.ie8Compat=document.documentMode==8;browser.ie7Compat=version==7&&!document.documentMode||document.documentMode==7;browser.ie6Compat=version<7||browser.quirks;browser.ie9above=version>8;browser.ie9below=version<9}if(browser.gecko){var geckoRelease=agent.match(/rv:([\d\.]+)/);if(geckoRelease){geckoRelease=geckoRelease[1].split(".");version=geckoRelease[0]*1e4+(geckoRelease[1]||0)*100+(geckoRelease[2]||0)*1}}if(/chrome\/(\d+\.\d)/i.test(agent)){browser.chrome=+RegExp["$1"]}if(/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(agent)&&!/chrome/i.test(agent)){browser.safari=+(RegExp["$1"]||RegExp["$2"])}if(browser.opera)version=parseFloat(opera.version());if(browser.webkit)version=parseFloat(agent.match(/ applewebkit\/(\d+)/)[1]);browser.version=version;browser.isCompatible=!browser.mobile&&(browser.ie&&version>=6||browser.gecko&&version>=10801||browser.opera&&version>=9.5||browser.air&&version>=1||browser.webkit&&version>=522||false);return browser}();var ie=browser.ie,webkit=browser.webkit,gecko=browser.gecko,opera=browser.opera;var utils=UM.utils={each:function(obj,iterator,context){if(obj==null)return;if(obj.length===+obj.length){for(var i=0,l=obj.length;i=start&&v===item){index=i;return false}});return index},removeItem:function(array,item){for(var i=0,l=array.length;i'](?:(amp|lt|quot|gt|#39|nbsp);)?/g,function(a,b){if(b){return a}else{return{"<":"<","&":"&",'"':""",">":">","'":"'"}[a]}}):""},html:function(str){return str?str.replace(/&((g|l|quo)t|amp|#39);/g,function(m){return{"<":"<","&":"&",""":'"',">":">","'":"'"}[m]}):""},cssStyleToDomStyle:function(){var test=document.createElement("div").style,cache={float:test.cssFloat!=undefined?"cssFloat":test.styleFloat!=undefined?"styleFloat":"float"};return function(cssName){return cache[cssName]||(cache[cssName]=cssName.toLowerCase().replace(/-./g,function(match){return match.charAt(1).toUpperCase()}))}}(),loadFile:function(){var tmpList=[];function getItem(doc,obj){try{for(var i=0,ci;ci=tmpList[i++];){if(ci.doc===doc&&ci.url==(obj.src||obj.href)){return ci}}}catch(e){return null}}return function(doc,obj,fn){var item=getItem(doc,obj);if(item){if(item.ready){fn&&fn()}else{item.funs.push(fn)}return}tmpList.push({doc:doc,url:obj.src||obj.href,funs:[fn]});if(!doc.body){var html=[];for(var p in obj){if(p=="tag")continue;html.push(p+'="'+obj[p]+'"')}doc.write("<"+obj.tag+" "+html.join(" ")+" >");return}if(obj.id&&doc.getElementById(obj.id)){return}var element=doc.createElement(obj.tag);delete obj.tag;for(var p in obj){element.setAttribute(p,obj[p])}element.onload=element.onreadystatechange=function(){if(!this.readyState||/loaded|complete/.test(this.readyState)){item=getItem(doc,obj);if(item.funs.length>0){item.ready=1;for(var fi;fi=item.funs.pop();){fi()}}element.onload=element.onreadystatechange=null}};element.onerror=function(){throw Error("The load "+(obj.href||obj.src)+" fails,check the url settings of file umeditor.config.js ")};doc.getElementsByTagName("head")[0].appendChild(element)}}(),isEmptyObject:function(obj){if(obj==null)return true;if(this.isArray(obj)||this.isString(obj))return obj.length===0;for(var key in obj)if(obj.hasOwnProperty(key))return false;return true},fixColor:function(name,value){if(/color/i.test(name)&&/rgba?/.test(value)){var array=value.split(",");if(array.length>3)return"";value="#";for(var i=0,color;color=array[i++];){color=parseInt(color.replace(/[^\d]/gi,""),10).toString(16);value+=color.length==1?"0"+color:color}value=value.toUpperCase()}return value},clone:function(source,target){var tmp;target=target||{};for(var i in source){if(source.hasOwnProperty(i)){tmp=source[i];if(typeof tmp=="object"){target[i]=utils.isArray(tmp)?[]:{};utils.clone(source[i],target[i])}else{target[i]=tmp}}}return target},transUnitToPx:function(val){if(!/(pt|cm)/.test(val)){return val}var unit;val.replace(/([\d.]+)(\w+)/,function(str,v,u){val=v;unit=u});switch(unit){case"cm":val=parseFloat(val)*25;break;case"pt":val=Math.round(parseFloat(val)*96/72)}return val+(val?"px":"")},cssRule:browser.ie&&browser.version!=11?function(key,style,doc){var indexList,index;doc=doc||document;if(doc.indexList){indexList=doc.indexList}else{indexList=doc.indexList={}}var sheetStyle;if(!indexList[key]){if(style===undefined){return""}sheetStyle=doc.createStyleSheet("",index=doc.styleSheets.length);indexList[key]=index}else{sheetStyle=doc.styleSheets[indexList[key]]}if(style===undefined){return sheetStyle.cssText}sheetStyle.cssText=style||""}:function(key,style,doc){doc=doc||document;var head=doc.getElementsByTagName("head")[0],node;if(!(node=doc.getElementById(key))){if(style===undefined){return""}node=doc.createElement("style");node.id=key;head.appendChild(node)}if(style===undefined){return node.innerHTML}if(style!==""){node.innerHTML=style}else{head.removeChild(node)}}};utils.each(["String","Function","Array","Number","RegExp","Object"],function(v){UM.utils["is"+v]=function(obj){return Object.prototype.toString.apply(obj)=="[object "+v+"]"}});var EventBase=UM.EventBase=function(){};EventBase.prototype={addListener:function(types,listener){types=utils.trim(types).split(" ");for(var i=0,ti;ti=types[i++];){getListener(this,ti,true).push(listener)}},removeListener:function(types,listener){types=utils.trim(types).split(" ");for(var i=0,ti;ti=types[i++];){utils.removeItem(getListener(this,ti)||[],listener)}},fireEvent:function(){var types=arguments[0];types=utils.trim(types).split(" ");for(var i=0,ti;ti=types[i++];){var listeners=getListener(this,ti),r,t,k;if(listeners){k=listeners.length;while(k--){if(!listeners[k])continue;t=listeners[k].apply(this,arguments);if(t===true){return t}if(t!==undefined){r=t}}}if(t=this["on"+ti.toLowerCase()]){r=t.apply(this,arguments)}}return r}};function getListener(obj,type,force){var allListeners;type=type.toLowerCase();return(allListeners=obj.__allListeners||force&&(obj.__allListeners={}))&&(allListeners[type]||force&&(allListeners[type]=[]))}var dtd=dom.dtd=function(){function _(s){for(var k in s){s[k.toUpperCase()]=s[k]}return s}var X=utils.extend2;var A=_({isindex:1,fieldset:1}),B=_({input:1,button:1,select:1,textarea:1,label:1}),C=X(_({a:1}),B),D=X({iframe:1},C),E=_({hr:1,ul:1,menu:1,div:1,blockquote:1,noscript:1,table:1,center:1,address:1,dir:1,pre:1,h5:1,dl:1,h4:1,noframes:1,h6:1,ol:1,h1:1,h3:1,h2:1}),F=_({ins:1,del:1,script:1,style:1}),G=X(_({b:1,acronym:1,bdo:1,var:1,"#":1,abbr:1,code:1,br:1,i:1,cite:1,kbd:1,u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,dfn:1,span:1}),F),H=X(_({sub:1,img:1,embed:1,object:1,sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1}),G),I=X(_({p:1}),H),J=X(_({iframe:1}),H,B),K=_({img:1,embed:1,noscript:1,br:1,kbd:1,center:1,button:1,basefont:1,h5:1,h4:1,samp:1,h6:1,ol:1,h1:1,h3:1,h2:1,form:1,font:1,"#":1,select:1,menu:1,ins:1,abbr:1,label:1,code:1,table:1,script:1,cite:1,input:1,iframe:1,strong:1,textarea:1,noframes:1,big:1,small:1,span:1,hr:1,sub:1,bdo:1,var:1,div:1,object:1,sup:1,strike:1,dir:1,map:1,dl:1,applet:1,del:1,isindex:1,fieldset:1,ul:1,b:1,acronym:1,a:1,blockquote:1,i:1,u:1,s:1,tt:1,address:1,q:1,pre:1,p:1,em:1,dfn:1}),L=X(_({a:0}),J),M=_({tr:1}),N=_({"#":1}),O=X(_({param:1}),K),P=X(_({form:1}),A,D,E,I),Q=_({li:1,ol:1,ul:1}),R=_({style:1,script:1}),S=_({base:1,link:1,meta:1,title:1}),T=X(S,R),U=_({head:1,body:1}),V=_({html:1});var block=_({address:1,blockquote:1,center:1,dir:1,div:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,isindex:1,menu:1,noframes:1,ol:1,p:1,pre:1,table:1,ul:1}),empty=_({area:1,base:1,basefont:1,br:1,col:1,command:1,dialog:1,embed:1,hr:1,img:1,input:1,isindex:1,keygen:1,link:1,meta:1,param:1,source:1,track:1,wbr:1});return _({$nonBodyContent:X(V,U,S),$block:block,$inline:L,$inlineWithA:X(_({a:1}),L),$body:X(_({script:1,style:1}),block),$cdata:_({script:1,style:1}),$empty:empty,$nonChild:_({iframe:1,textarea:1}),$listItem:_({dd:1,dt:1,li:1}),$list:_({ul:1,ol:1,dl:1}),$isNotEmpty:_({table:1,ul:1,ol:1,dl:1,iframe:1,area:1,base:1,col:1,hr:1,img:1,embed:1,input:1,link:1,meta:1,param:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1}),$removeEmpty:_({a:1,abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,var:1}),$removeEmptyBlock:_({p:1,div:1}),$tableContent:_({caption:1,col:1,colgroup:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1,table:1}),$notTransContent:_({pre:1,script:1,style:1,textarea:1}),html:U,head:T,style:N,script:N,body:P,base:{},link:{},meta:{},title:N,col:{},tr:_({td:1,th:1}),img:{},embed:{},colgroup:_({thead:1,col:1,tbody:1,tr:1,tfoot:1}),noscript:P,td:P,br:{},th:P,center:P,kbd:L,button:X(I,E),basefont:{},h5:L,h4:L,samp:L,h6:L,ol:Q,h1:L,h3:L,option:N,h2:L,form:X(A,D,E,I),select:_({optgroup:1,option:1}),font:L,ins:L,menu:Q,abbr:L,label:L,table:_({thead:1,col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1}),code:L,tfoot:M,cite:L,li:P,input:{},iframe:P,strong:L,textarea:N,noframes:P,big:L,small:L,span:_({"#":1,br:1,b:1,strong:1,u:1,i:1,em:1,sub:1,sup:1,strike:1,span:1}),hr:L,dt:L,sub:L,optgroup:_({option:1}),param:{},bdo:L,var:L,div:P,object:O,sup:L,dd:P,strike:L,area:{},dir:Q,map:X(_({area:1,form:1,p:1}),A,F,E),applet:O,dl:_({dt:1,dd:1}),del:L,isindex:{},fieldset:X(_({legend:1}),K),thead:M,ul:Q,acronym:L,b:L,a:X(_({a:1}),J),blockquote:X(_({td:1,tr:1,tbody:1,li:1}),P),caption:L,i:L,u:L,tbody:M,s:L,address:X(D,I),tt:L,legend:L,q:L,pre:X(G,C),p:X(_({a:1}),L),em:L,dfn:L})}();function getDomNode(node,start,ltr,startFromChild,fn,guard){var tmpNode=startFromChild&&node[start],parent;!tmpNode&&(tmpNode=node[ltr]);while(!tmpNode&&(parent=(parent||node).parentNode)){if(parent.tagName=="BODY"||guard&&!guard(parent)){return null}tmpNode=parent[ltr]}if(tmpNode&&fn&&!fn(tmpNode)){return getDomNode(tmpNode,start,ltr,false,fn)}return tmpNode}var attrFix=ie&&browser.version<9?{tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder"}:{tabindex:"tabIndex",readonly:"readOnly"},styleBlock=utils.listToMap(["-webkit-box","-moz-box","block","list-item","table","table-row-group","table-header-group","table-footer-group","table-row","table-column-group","table-column","table-cell","table-caption"]);var domUtils=dom.domUtils={NODE_ELEMENT:1,NODE_DOCUMENT:9,NODE_TEXT:3,NODE_COMMENT:8,NODE_DOCUMENT_FRAGMENT:11,POSITION_IDENTICAL:0,POSITION_DISCONNECTED:1,POSITION_FOLLOWING:2,POSITION_PRECEDING:4,POSITION_IS_CONTAINED:8,POSITION_CONTAINS:16,fillChar:ie&&browser.version=="6"?"\ufeff":"​",keys:{8:1,46:1,16:1,17:1,18:1,37:1,38:1,39:1,40:1,13:1},breakParent:function(node,parent){var tmpNode,parentClone=node,clone=node,leftNodes,rightNodes;do{parentClone=parentClone.parentNode;if(leftNodes){tmpNode=parentClone.cloneNode(false);tmpNode.appendChild(leftNodes);leftNodes=tmpNode;tmpNode=parentClone.cloneNode(false);tmpNode.appendChild(rightNodes);rightNodes=tmpNode}else{leftNodes=parentClone.cloneNode(false);rightNodes=leftNodes.cloneNode(false)}while(tmpNode=clone.previousSibling){leftNodes.insertBefore(tmpNode,leftNodes.firstChild)}while(tmpNode=clone.nextSibling){rightNodes.appendChild(tmpNode)}clone=parentClone}while(parent!==parentClone);tmpNode=parent.parentNode;tmpNode.insertBefore(leftNodes,parent);tmpNode.insertBefore(rightNodes,parent);tmpNode.insertBefore(node,rightNodes);domUtils.remove(parent);return node},trimWhiteTextNode:function(node){function remove(dir){var child;while((child=node[dir])&&child.nodeType==3&&domUtils.isWhitespace(child)){node.removeChild(child)}}remove("firstChild");remove("lastChild")},getPosition:function(nodeA,nodeB){if(nodeA===nodeB){return 0}var node,parentsA=[nodeA],parentsB=[nodeB];node=nodeA;while(node=node.parentNode){if(node===nodeB){return 10}parentsA.push(node)}node=nodeB;while(node=node.parentNode){if(node===nodeA){return 20}parentsB.push(node)}parentsA.reverse();parentsB.reverse();if(parentsA[0]!==parentsB[0]){return 1}var i=-1;while(i++,parentsA[i]===parentsB[i]){}nodeA=parentsA[i];nodeB=parentsB[i];while(nodeA=nodeA.nextSibling){if(nodeA===nodeB){return 4}}return 2},getNodeIndex:function(node,ignoreTextNode){var preNode=node,i=0;while(preNode=preNode.previousSibling){if(ignoreTextNode&&preNode.nodeType==3){if(preNode.nodeType!=preNode.nextSibling.nodeType){i++}continue}i++}return i},inDoc:function(node,doc){return domUtils.getPosition(node,doc)==10},findParent:function(node,filterFn,includeSelf){if(node&&!domUtils.isBody(node)){node=includeSelf?node:node.parentNode;while(node){if(!filterFn||filterFn(node)||domUtils.isBody(node)){return filterFn&&!filterFn(node)&&domUtils.isBody(node)?null:node}node=node.parentNode}}return null},findParentByTagName:function(node,tagNames,includeSelf,excludeFn){tagNames=utils.listToMap(utils.isArray(tagNames)?tagNames:[tagNames]);return domUtils.findParent(node,function(node){return tagNames[node.tagName]&&!(excludeFn&&excludeFn(node))},includeSelf)},findParents:function(node,includeSelf,filterFn,closerFirst){var parents=includeSelf&&(filterFn&&filterFn(node)||!filterFn)?[node]:[];while(node=domUtils.findParent(node,filterFn)){parents.push(node)}return closerFirst?parents:parents.reverse()},insertAfter:function(node,newNode){return node.parentNode.insertBefore(newNode,node.nextSibling)},remove:function(node,keepChildren){var parent=node.parentNode,child;if(parent){if(keepChildren&&node.hasChildNodes()){while(child=node.firstChild){parent.insertBefore(child,node)}}parent.removeChild(node)}return node},getNextDomNode:function(node,startFromChild,filterFn,guard){return getDomNode(node,"firstChild","nextSibling",startFromChild,filterFn,guard)},getPreDomNode:function(node,startFromChild,filterFn,guard){return getDomNode(node,"lastChild","previousSibling",startFromChild,filterFn,guard)},isBookmarkNode:function(node){return node.nodeType==1&&node.id&&/^_baidu_bookmark_/i.test(node.id)},getWindow:function(node){var doc=node.ownerDocument||node;return doc.defaultView||doc.parentWindow},getCommonAncestor:function(nodeA,nodeB){if(nodeA===nodeB)return nodeA;var parentsA=[nodeA],parentsB=[nodeB],parent=nodeA,i=-1;while(parent=parent.parentNode){if(parent===nodeB){return parent}parentsA.push(parent)}parent=nodeB;while(parent=parent.parentNode){if(parent===nodeA)return parent;parentsB.push(parent)}parentsA.reverse();parentsB.reverse();while(i++,parentsA[i]===parentsB[i]){}return i==0?null:parentsA[i-1]},clearEmptySibling:function(node,ignoreNext,ignorePre){function clear(next,dir){var tmpNode;while(next&&!domUtils.isBookmarkNode(next)&&(domUtils.isEmptyInlineElement(next)||!new RegExp("[^\t\n\r"+domUtils.fillChar+"]").test(next.nodeValue))){tmpNode=next[dir];domUtils.remove(next);next=tmpNode}}!ignoreNext&&clear(node.nextSibling,"nextSibling");!ignorePre&&clear(node.previousSibling,"previousSibling")},split:function(node,offset){var doc=node.ownerDocument;if(browser.ie&&offset==node.nodeValue.length){var next=doc.createTextNode("");return domUtils.insertAfter(node,next)}var retval=node.splitText(offset);if(browser.ie8){var tmpNode=doc.createTextNode("");domUtils.insertAfter(retval,tmpNode);domUtils.remove(tmpNode)}return retval},isWhitespace:function(node){return!new RegExp("[^ \t\n\r"+domUtils.fillChar+"]").test(node.nodeValue)},getXY:function(element){var x=0,y=0;while(element.offsetParent){y+=element.offsetTop;x+=element.offsetLeft;element=element.offsetParent}return{x:x,y:y}},isEmptyInlineElement:function(node){if(node.nodeType!=1||!dtd.$removeEmpty[node.tagName]){return 0}node=node.firstChild;while(node){if(domUtils.isBookmarkNode(node)){return 0}if(node.nodeType==1&&!domUtils.isEmptyInlineElement(node)||node.nodeType==3&&!domUtils.isWhitespace(node)){return 0}node=node.nextSibling}return 1},isBlockElm:function(node){return node.nodeType==1&&(dtd.$block[node.tagName]||styleBlock[domUtils.getComputedStyle(node,"display")])&&!dtd.$nonChild[node.tagName]},getElementsByTagName:function(node,name,filter){if(filter&&utils.isString(filter)){var className=filter;filter=function(node){var result=false;$.each(utils.trim(className).replace(/[ ]{2,}/g," ").split(" "),function(i,v){if($(node).hasClass(v)){result=true;return false}});return result}}name=utils.trim(name).replace(/[ ]{2,}/g," ").split(" ");var arr=[];for(var n=0,ni;ni=name[n++];){var list=node.getElementsByTagName(ni);for(var i=0,ci;ci=list[i++];){if(!filter||filter(ci))arr.push(ci)}}return arr},unSelectable:ie&&browser.ie9below||browser.opera?function(node){node.onselectstart=function(){return false};node.onclick=node.onkeyup=node.onkeydown=function(){return false};node.unselectable="on";node.setAttribute("unselectable","on");for(var i=0,ci;ci=node.all[i++];){switch(ci.tagName.toLowerCase()){case"iframe":case"textarea":case"input":case"select":break;default:ci.unselectable="on";node.setAttribute("unselectable","on")}}}:function(node){node.style.MozUserSelect=node.style.webkitUserSelect=node.style.msUserSelect=node.style.KhtmlUserSelect="none"},removeAttributes:function(node,attrNames){attrNames=utils.isArray(attrNames)?attrNames:utils.trim(attrNames).replace(/[ ]{2,}/g," ").split(" ");for(var i=0,ci;ci=attrNames[i++];){ci=attrFix[ci]||ci;switch(ci){case"className":node[ci]="";break;case"style":node.style.cssText="";!browser.ie&&node.removeAttributeNode(node.getAttributeNode("style"))}node.removeAttribute(ci)}},createElement:function(doc,tag,attrs){return domUtils.setAttributes(doc.createElement(tag),attrs)},setAttributes:function(node,attrs){for(var attr in attrs){if(attrs.hasOwnProperty(attr)){var value=attrs[attr];switch(attr){case"class":node.className=value;break;case"style":node.style.cssText=node.style.cssText+";"+value;break;case"innerHTML":node[attr]=value;break;case"value":node.value=value;break;default:node.setAttribute(attrFix[attr]||attr,value)}}}return node},getComputedStyle:function(element,styleName){return utils.transUnitToPx(utils.fixColor(styleName,$(element).css(styleName)))},preventDefault:function(evt){evt.preventDefault?evt.preventDefault():evt.returnValue=false},removeStyle:function(element,name){if(browser.ie){if(name=="color"){name="(^|;)"+name}element.style.cssText=element.style.cssText.replace(new RegExp(name+"[^:]*:[^;]+;?","ig"),"")}else{if(element.style.removeProperty){element.style.removeProperty(name)}else{element.style.removeAttribute(utils.cssStyleToDomStyle(name))}}if(!element.style.cssText){domUtils.removeAttributes(element,["style"])}},getStyle:function(element,name){var value=element.style[utils.cssStyleToDomStyle(name)];return utils.fixColor(name,value)},setStyle:function(element,name,value){element.style[utils.cssStyleToDomStyle(name)]=value;if(!utils.trim(element.style.cssText)){this.removeAttributes(element,"style")}},removeDirtyAttr:function(node){for(var i=0,ci,nodes=node.getElementsByTagName("*");ci=nodes[i++];){ci.removeAttribute("_moz_dirty")}node.removeAttribute("_moz_dirty")},getChildCount:function(node,fn){var count=0,first=node.firstChild;fn=fn||function(){return 1};while(first){if(fn(first)){count++}first=first.nextSibling}return count},isEmptyNode:function(node){return!node.firstChild||domUtils.getChildCount(node,function(node){return!domUtils.isBr(node)&&!domUtils.isBookmarkNode(node)&&!domUtils.isWhitespace(node)})==0},isBr:function(node){return node.nodeType==1&&node.tagName=="BR"},isEmptyBlock:function(node,reg){if(node.nodeType!=1)return 0;reg=reg||new RegExp("[ \t\r\n"+domUtils.fillChar+"]","g");if(node[browser.ie?"innerText":"textContent"].replace(reg,"").length>0){return 0}for(var n in dtd.$isNotEmpty){if(node.getElementsByTagName(n).length){return 0}}return 1},isCustomeNode:function(node){return node.nodeType==1&&node.getAttribute("_ue_custom_node_")},fillNode:function(doc,node){var tmpNode=browser.ie?doc.createTextNode(domUtils.fillChar):doc.createElement("br");node.innerHTML="";node.appendChild(tmpNode)},isBoundaryNode:function(node,dir){var tmp;while(!domUtils.isBody(node)){tmp=node;node=node.parentNode;if(tmp!==node[dir]){return false}}return true},isFillChar:function(node,isInStart){return node.nodeType==3&&!node.nodeValue.replace(new RegExp((isInStart?"^":"")+domUtils.fillChar),"").length},isBody:function(node){return $(node).hasClass("edui-body-container")}};var fillCharReg=new RegExp(domUtils.fillChar,"g");(function(){var guid=0,fillChar=domUtils.fillChar,fillData;function updateCollapse(range){range.collapsed=range.startContainer&&range.endContainer&&range.startContainer===range.endContainer&&range.startOffset==range.endOffset}function selectOneNode(rng){return!rng.collapsed&&rng.startContainer.nodeType==1&&rng.startContainer===rng.endContainer&&rng.endOffset-rng.startOffset==1}function setEndPoint(toStart,node,offset,range){if(node.nodeType==1&&(dtd.$empty[node.tagName]||dtd.$nonChild[node.tagName])){offset=domUtils.getNodeIndex(node)+(toStart?0:1);node=node.parentNode}if(toStart){range.startContainer=node;range.startOffset=offset;if(!range.endContainer){range.collapse(true)}}else{range.endContainer=node;range.endOffset=offset;if(!range.startContainer){range.collapse(false)}}updateCollapse(range);return range}var Range=dom.Range=function(document,body){var me=this;me.startContainer=me.startOffset=me.endContainer=me.endOffset=null;me.document=document;me.collapsed=true;me.body=body};function removeFillData(doc,excludeNode){try{if(fillData&&domUtils.inDoc(fillData,doc)){if(!fillData.nodeValue.replace(fillCharReg,"").length){var tmpNode=fillData.parentNode;domUtils.remove(fillData);while(tmpNode&&domUtils.isEmptyInlineElement(tmpNode)&&(browser.safari?!(domUtils.getPosition(tmpNode,excludeNode)&domUtils.POSITION_CONTAINS):!tmpNode.contains(excludeNode))){fillData=tmpNode.parentNode;domUtils.remove(tmpNode);tmpNode=fillData}}else{fillData.nodeValue=fillData.nodeValue.replace(fillCharReg,"")}}}catch(e){}}function mergeSibling(node,dir){var tmpNode;node=node[dir];while(node&&domUtils.isFillChar(node)){tmpNode=node[dir];domUtils.remove(node);node=tmpNode}}function execContentsAction(range,action){var start=range.startContainer,end=range.endContainer,startOffset=range.startOffset,endOffset=range.endOffset,doc=range.document,frag=doc.createDocumentFragment(),tmpStart,tmpEnd;if(start.nodeType==1){start=start.childNodes[startOffset]||(tmpStart=start.appendChild(doc.createTextNode("")))}if(end.nodeType==1){end=end.childNodes[endOffset]||(tmpEnd=end.appendChild(doc.createTextNode("")))}if(start===end&&start.nodeType==3){frag.appendChild(doc.createTextNode(start.substringData(startOffset,endOffset-startOffset)));if(action){start.deleteData(startOffset,endOffset-startOffset);range.collapse(true)}return frag}var current,currentLevel,clone=frag,startParents=domUtils.findParents(start,true),endParents=domUtils.findParents(end,true);for(var i=0;startParents[i]==endParents[i];){i++}for(var j=i,si;si=startParents[j];j++){current=si.nextSibling;if(si==start){if(!tmpStart){if(range.startContainer.nodeType==3){clone.appendChild(doc.createTextNode(start.nodeValue.slice(startOffset)));if(action){start.deleteData(startOffset,start.nodeValue.length-startOffset)}}else{clone.appendChild(!action?start.cloneNode(true):start)}}}else{currentLevel=si.cloneNode(false);clone.appendChild(currentLevel)}while(current){if(current===end||current===endParents[j]){break}si=current.nextSibling;clone.appendChild(!action?current.cloneNode(true):current);current=si}clone=currentLevel}clone=frag;if(!startParents[i]){clone.appendChild(startParents[i-1].cloneNode(false));clone=clone.firstChild}for(var j=i,ei;ei=endParents[j];j++){current=ei.previousSibling;if(ei==end){if(!tmpEnd&&range.endContainer.nodeType==3){clone.appendChild(doc.createTextNode(end.substringData(0,endOffset)));if(action){end.deleteData(0,endOffset)}}}else{currentLevel=ei.cloneNode(false);clone.appendChild(currentLevel)}if(j!=i||!startParents[i]){while(current){if(current===start){break}ei=current.previousSibling;clone.insertBefore(!action?current.cloneNode(true):current,clone.firstChild);current=ei}}clone=currentLevel}if(action){range.setStartBefore(!endParents[i]?endParents[i-1]:!startParents[i]?startParents[i-1]:endParents[i]).collapse(true)}tmpStart&&domUtils.remove(tmpStart);tmpEnd&&domUtils.remove(tmpEnd);return frag}Range.prototype={deleteContents:function(){var txt;if(!this.collapsed){execContentsAction(this,1)}if(browser.webkit){txt=this.startContainer;if(txt.nodeType==3&&!txt.nodeValue.length){this.setStartBefore(txt).collapse(true);domUtils.remove(txt)}}return this},inFillChar:function(){var start=this.startContainer;if(this.collapsed&&start.nodeType==3&&start.nodeValue.replace(new RegExp("^"+domUtils.fillChar),"").length+1==start.nodeValue.length){return true}return false},setStart:function(node,offset){return setEndPoint(true,node,offset,this)},setEnd:function(node,offset){return setEndPoint(false,node,offset,this)},setStartAfter:function(node){return this.setStart(node.parentNode,domUtils.getNodeIndex(node)+1)},setStartBefore:function(node){return this.setStart(node.parentNode,domUtils.getNodeIndex(node))},setEndAfter:function(node){return this.setEnd(node.parentNode,domUtils.getNodeIndex(node)+1)},setEndBefore:function(node){return this.setEnd(node.parentNode,domUtils.getNodeIndex(node))},setStartAtFirst:function(node){return this.setStart(node,0)},setStartAtLast:function(node){return this.setStart(node,node.nodeType==3?node.nodeValue.length:node.childNodes.length)},setEndAtFirst:function(node){return this.setEnd(node,0)},setEndAtLast:function(node){return this.setEnd(node,node.nodeType==3?node.nodeValue.length:node.childNodes.length)},selectNode:function(node){return this.setStartBefore(node).setEndAfter(node)},selectNodeContents:function(node){return this.setStart(node,0).setEndAtLast(node)},cloneRange:function(){var me=this;return new Range(me.document).setStart(me.startContainer,me.startOffset).setEnd(me.endContainer,me.endOffset)},collapse:function(toStart){var me=this;if(toStart){me.endContainer=me.startContainer;me.endOffset=me.startOffset}else{me.startContainer=me.endContainer;me.startOffset=me.endOffset}me.collapsed=true;return me},shrinkBoundary:function(ignoreEnd){var me=this,child,collapsed=me.collapsed;function check(node){return node.nodeType==1&&!domUtils.isBookmarkNode(node)&&!dtd.$empty[node.tagName]&&!dtd.$nonChild[node.tagName]}while(me.startContainer.nodeType==1&&(child=me.startContainer.childNodes[me.startOffset])&&check(child)){me.setStart(child,0)}if(collapsed){return me.collapse(true)}if(!ignoreEnd){while(me.endContainer.nodeType==1&&me.endOffset>0&&(child=me.endContainer.childNodes[me.endOffset-1])&&check(child)){me.setEnd(child,child.childNodes.length)}}return me},trimBoundary:function(ignoreEnd){this.txtToElmBoundary();var start=this.startContainer,offset=this.startOffset,collapsed=this.collapsed,end=this.endContainer;if(start.nodeType==3){if(offset==0){this.setStartBefore(start)}else{if(offset>=start.nodeValue.length){this.setStartAfter(start)}else{var textNode=domUtils.split(start,offset);if(start===end){this.setEnd(textNode,this.endOffset-offset)}else if(start.parentNode===end){this.endOffset+=1}this.setStartBefore(textNode)}}if(collapsed){return this.collapse(true)}}if(!ignoreEnd){offset=this.endOffset;end=this.endContainer;if(end.nodeType==3){if(offset==0){this.setEndBefore(end)}else{offset=container.nodeValue.length){r["set"+c.replace(/(\w)/,function(a){return a.toUpperCase()})+"After"](container)}}}if(ignoreCollapsed||!this.collapsed){adjust(this,"start");adjust(this,"end")}return this},insertNode:function(node){var first=node,length=1;if(node.nodeType==11){first=node.firstChild;length=node.childNodes.length}this.trimBoundary(true);var start=this.startContainer,offset=this.startOffset;var nextNode=start.childNodes[offset];if(nextNode){start.insertBefore(node,nextNode)}else{start.appendChild(node)}if(first.parentNode===this.endContainer){this.endOffset=this.endOffset+length}return this.setStartBefore(first)},setCursor:function(toEnd,noFillData){return this.collapse(!toEnd).select(noFillData)},createBookmark:function(serialize,same){var endNode,startNode=this.document.createElement("span");startNode.style.cssText="display:none;line-height:0px;";startNode.appendChild(this.document.createTextNode("‍"));startNode.id="_baidu_bookmark_start_"+(same?"":guid++);if(!this.collapsed){endNode=startNode.cloneNode(true);endNode.id="_baidu_bookmark_end_"+(same?"":guid++)}this.insertNode(startNode);if(endNode){this.collapse().insertNode(endNode).setEndBefore(endNode)}this.setStartAfter(startNode);return{start:serialize?startNode.id:startNode,end:endNode?serialize?endNode.id:endNode:null,id:serialize}},moveToBookmark:function(bookmark){var start=bookmark.id?this.document.getElementById(bookmark.start):bookmark.start,end=bookmark.end&&bookmark.id?this.document.getElementById(bookmark.end):bookmark.end;this.setStartBefore(start);domUtils.remove(start);if(end){this.setEndBefore(end);domUtils.remove(end)}else{this.collapse(true)}return this},adjustmentBoundary:function(){if(!this.collapsed){while(!domUtils.isBody(this.startContainer)&&this.startOffset==this.startContainer[this.startContainer.nodeType==3?"nodeValue":"childNodes"].length&&this.startContainer[this.startContainer.nodeType==3?"nodeValue":"childNodes"].length){this.setStartAfter(this.startContainer)}while(!domUtils.isBody(this.endContainer)&&!this.endOffset&&this.endContainer[this.endContainer.nodeType==3?"nodeValue":"childNodes"].length){this.setEndBefore(this.endContainer)}}return this},getClosedNode:function(){var node;if(!this.collapsed){var range=this.cloneRange().adjustmentBoundary().shrinkBoundary();if(selectOneNode(range)){var child=range.startContainer.childNodes[range.startOffset];if(child&&child.nodeType==1&&(dtd.$empty[child.tagName]||dtd.$nonChild[child.tagName])){node=child}}}return node},select:browser.ie?function(noFillData,textRange){var nativeRange;if(!this.collapsed)this.shrinkBoundary();var node=this.getClosedNode();if(node&&!textRange){try{nativeRange=this.document.body.createControlRange();nativeRange.addElement(node);nativeRange.select()}catch(e){}return this}var bookmark=this.createBookmark(),start=bookmark.start,end;nativeRange=this.document.body.createTextRange();nativeRange.moveToElementText(start);nativeRange.moveStart("character",1);if(!this.collapsed){var nativeRangeEnd=this.document.body.createTextRange();end=bookmark.end;nativeRangeEnd.moveToElementText(end);nativeRange.setEndPoint("EndToEnd",nativeRangeEnd)}else{if(!noFillData&&this.startContainer.nodeType!=3){var tmpText=this.document.createTextNode(fillChar),tmp=this.document.createElement("span");tmp.appendChild(this.document.createTextNode(fillChar));start.parentNode.insertBefore(tmp,start);start.parentNode.insertBefore(tmpText,start);removeFillData(this.document,tmpText);fillData=tmpText;mergeSibling(tmp,"previousSibling");mergeSibling(start,"nextSibling");nativeRange.moveStart("character",-1);nativeRange.collapse(true)}}this.moveToBookmark(bookmark);tmp&&domUtils.remove(tmp);try{nativeRange.select()}catch(e){}return this}:function(notInsertFillData){function checkOffset(rng){function check(node,offset,dir){if(node.nodeType==3&&node.nodeValue.length ');this.cloneRange().insertNode($span.get(0));var winScrollTop=$(window).scrollTop(),winHeight=$(window).height(),spanTop=$span.offset().top;if(spanTopwinScrollTop+winHeight){if(spanTop>winScrollTop+winHeight){window.scrollTo(0,spanTop-winHeight+$span.height())}else{window.scrollTo(0,winScrollTop-spanTop)}}$span.remove()},getOffset:function(){var bk=this.createBookmark();var offset=$(bk.start).css("display","inline-block").offset();this.moveToBookmark(bk);return offset}}})();(function(){function getBoundaryInformation(range,start){var getIndex=domUtils.getNodeIndex;range=range.duplicate();range.collapse(start);var parent=range.parentElement();if(!parent.hasChildNodes()){return{container:parent,offset:0}}var siblings=parent.children,child,testRange=range.duplicate(),startIndex=0,endIndex=siblings.length-1,index=-1,distance;while(startIndex<=endIndex){index=Math.floor((startIndex+endIndex)/2);child=siblings[index];testRange.moveToElementText(child);var position=testRange.compareEndPoints("StartToStart",range);if(position>0){endIndex=index-1}else if(position<0){startIndex=index+1}else{return{container:parent,offset:getIndex(child)}}}if(index==-1){testRange.moveToElementText(parent);testRange.setEndPoint("StartToStart",range);distance=testRange.text.replace(/(\r\n|\r)/g,"\n").length;siblings=parent.childNodes;if(!distance){child=siblings[siblings.length-1];return{container:child,offset:child.nodeValue.length}}var i=siblings.length;while(distance>0){distance-=siblings[--i].nodeValue.length}return{container:siblings[i],offset:-distance}}testRange.collapse(position>0);testRange.setEndPoint(position>0?"StartToStart":"EndToStart",range);distance=testRange.text.replace(/(\r\n|\r)/g,"\n").length;if(!distance){return dtd.$empty[child.tagName]||dtd.$nonChild[child.tagName]?{container:parent,offset:getIndex(child)+(position>0?0:1)}:{container:child,offset:position>0?0:child.childNodes.length}}while(distance>0){try{var pre=child;child=child[position>0?"previousSibling":"nextSibling"];distance-=child.nodeValue.length}catch(e){return{container:parent,offset:getIndex(pre)}}}return{container:child,offset:position>0?-distance:child.nodeValue.length+distance}}function transformIERangeToRange(ieRange,range){if(ieRange.item){range.selectNode(ieRange.item(0))}else{var bi=getBoundaryInformation(ieRange,true);range.setStart(bi.container,bi.offset);if(ieRange.compareEndPoints("StartToEnd",ieRange)!=0){bi=getBoundaryInformation(ieRange,false);range.setEnd(bi.container,bi.offset)}}return range}function _getIERange(sel,txtRange){var ieRange;try{ieRange=sel.getNative(txtRange).createRange()}catch(e){return null}var el=ieRange.item?ieRange.item(0):ieRange.parentElement();if((el.ownerDocument||el)===sel.document){return ieRange}return null}var Selection=dom.Selection=function(doc,body){var me=this;me.document=doc;me.body=body;if(browser.ie9below){$(body).on("beforedeactivate",function(){me._bakIERange=me.getIERange()}).on("activate",function(){try{var ieNativRng=_getIERange(me);if((!ieNativRng||!me.rangeInBody(ieNativRng))&&me._bakIERange){me._bakIERange.select()}}catch(ex){}me._bakIERange=null})}};Selection.prototype={hasNativeRange:function(){var rng;if(!browser.ie||browser.ie9above){var nativeSel=this.getNative();if(!nativeSel.rangeCount){return false}rng=nativeSel.getRangeAt(0)}else{rng=_getIERange(this)}return this.rangeInBody(rng)},getNative:function(txtRange){var doc=this.document;try{return!doc?null:browser.ie9below||txtRange?doc.selection:domUtils.getWindow(doc).getSelection()}catch(e){return null}},getIERange:function(txtRange){var ieRange=_getIERange(this,txtRange);if(!ieRange||!this.rangeInBody(ieRange,txtRange)){if(this._bakIERange){return this._bakIERange}}return ieRange},rangeInBody:function(rng,txtRange){var node=browser.ie9below||txtRange?rng.item?rng.item():rng.parentElement():rng.startContainer;return node===this.body||domUtils.inDoc(node,this.body)},cache:function(){this.clear();this._cachedRange=this.getRange();this._cachedStartElement=this.getStart();this._cachedStartElementPath=this.getStartElementPath()},getStartElementPath:function(){if(this._cachedStartElementPath){return this._cachedStartElementPath}var start=this.getStart();if(start){return domUtils.findParents(start,true,null,true)}return[]},clear:function(){this._cachedStartElementPath=this._cachedRange=this._cachedStartElement=null},isFocus:function(){return this.hasNativeRange()},getRange:function(){var me=this;function optimze(range){var child=me.body.firstChild,collapsed=range.collapsed;while(child&&child.firstChild){range.setStart(child,0);child=child.firstChild}if(!range.startContainer){range.setStart(me.body,0)}if(collapsed){range.collapse(true)}}if(me._cachedRange!=null){return this._cachedRange}var range=new dom.Range(me.document,me.body);if(browser.ie9below){var nativeRange=me.getIERange();if(nativeRange&&this.rangeInBody(nativeRange)){try{transformIERangeToRange(nativeRange,range)}catch(e){optimze(range)}}else{optimze(range)}}else{var sel=me.getNative();if(sel&&sel.rangeCount&&me.rangeInBody(sel.getRangeAt(0))){var firstRange=sel.getRangeAt(0);var lastRange=sel.getRangeAt(sel.rangeCount-1);range.setStart(firstRange.startContainer,firstRange.startOffset).setEnd(lastRange.endContainer,lastRange.endOffset);if(range.collapsed&&domUtils.isBody(range.startContainer)&&!range.startOffset){optimze(range)}}else{if(this._bakRange&&(this._bakRange.startContainer===this.body||domUtils.inDoc(this._bakRange.startContainer,this.body))){return this._bakRange}optimze(range)}}return this._bakRange=range},getStart:function(){if(this._cachedStartElement){return this._cachedStartElement}var range=browser.ie9below?this.getIERange():this.getRange(),tmpRange,start,tmp,parent;if(browser.ie9below){if(!range){return this.document.body.firstChild}if(range.item){return range.item(0)}tmpRange=range.duplicate();tmpRange.text.length>0&&tmpRange.moveStart("character",1);tmpRange.collapse(1);start=tmpRange.parentElement();parent=tmp=range.parentElement();while(tmp=tmp.parentNode){if(tmp==start){start=parent;break}}}else{start=range.startContainer;if(start.nodeType==1&&start.hasChildNodes()){start=start.childNodes[Math.min(start.childNodes.length-1,range.startOffset)]}if(start.nodeType==3){return start.parentNode}}return start},getText:function(){var nativeSel,nativeRange;if(this.isFocus()&&(nativeSel=this.getNative())){nativeRange=browser.ie9below?nativeSel.createRange():nativeSel.getRangeAt(0);return browser.ie9below?nativeRange.text:nativeRange.toString()}return""}}})();(function(){var uid=0,_selectionChangeTimer;function setValue(form,editor){var textarea;if(editor.textarea){if(utils.isString(editor.textarea)){for(var i=0,ti,tis=domUtils.getElementsByTagName(form,"textarea");ti=tis[i++];){if(ti.id=="umeditor_textarea_"+editor.options.textarea){textarea=ti;break}}}else{textarea=editor.textarea}}if(!textarea){form.appendChild(textarea=domUtils.createElement(document,"textarea",{name:editor.options.textarea,id:"umeditor_textarea_"+editor.options.textarea,style:"display:none"}));editor.textarea=textarea}textarea.value=editor.hasContents()?editor.options.allHtmlEnabled?editor.getAllHtml():editor.getContent(null,null,true):""}function loadPlugins(me){for(var pi in UM.plugins){if(me.options.excludePlugins.indexOf(pi)==-1){UM.plugins[pi].call(me);me.plugins[pi]=1}}me.langIsReady=true;me.fireEvent("langReady")}function checkCurLang(I18N){for(var lang in I18N){return lang}}var Editor=UM.Editor=function(options){var me=this;me.uid=uid++;EventBase.call(me);me.commands={};me.options=utils.extend(utils.clone(options||{}),UMEDITOR_CONFIG,true);me.shortcutkeys={};me.inputRules=[];me.outputRules=[];me.setOpt({isShow:true,initialContent:"",initialStyle:"",autoClearinitialContent:false,textarea:"editorValue",focus:false,focusInEnd:true,autoClearEmptyNode:true,fullscreen:false,readonly:false,zIndex:999,enterTag:"p",lang:"zh-cn",langPath:me.options.UMEDITOR_HOME_URL+"lang/",theme:"default",themePath:me.options.UMEDITOR_HOME_URL+"themes/",allHtmlEnabled:false,autoSyncData:true,autoHeightEnabled:true,excludePlugins:""});me.plugins={};if(!utils.isEmptyObject(UM.I18N)){me.options.lang=checkCurLang(UM.I18N);loadPlugins(me)}else{utils.loadFile(document,{src:me.options.langPath+me.options.lang+"/"+me.options.lang+".js",tag:"script",type:"text/javascript",defer:"defer"},function(){loadPlugins(me)})}};Editor.prototype={ready:function(fn){var me=this;if(fn){me.isReady?fn.apply(me):me.addListener("ready",fn)}},setOpt:function(key,val){var obj={};if(utils.isString(key)){obj[key]=val}else{obj=key}utils.extend(this.options,obj,true)},getOpt:function(key){return this.options[key]||""},destroy:function(){var me=this;me.fireEvent("destroy");var container=me.container.parentNode;if(container===document.body){container=me.container}var textarea=me.textarea;if(!textarea){textarea=document.createElement("textarea");container.parentNode.insertBefore(textarea,container)}else{textarea.style.display=""}textarea.style.width=me.body.offsetWidth+"px";textarea.style.height=me.body.offsetHeight+"px";textarea.value=me.getContent();textarea.id=me.key;if(container.contains(textarea)){$(textarea).insertBefore(container)}container.innerHTML="";domUtils.remove(container);UM.clearCache(me.id);for(var p in me){if(me.hasOwnProperty(p)){delete this[p]}}},initialCont:function(holder){if(holder){holder.getAttribute("name")&&(this.options.textarea=holder.getAttribute("name"));if(holder&&/script|textarea/gi.test(holder.tagName)){var newDiv=document.createElement("div");holder.parentNode.insertBefore(newDiv,holder);this.options.initialContent=UM.htmlparser(holder.value||holder.innerHTML||this.options.initialContent).toHtml();holder.className&&(newDiv.className=holder.className);holder.style.cssText&&(newDiv.style.cssText=holder.style.cssText);if(/textarea/i.test(holder.tagName)){this.textarea=holder;this.textarea.style.display="none"}else{holder.parentNode.removeChild(holder);holder.id&&(newDiv.id=holder.id)}holder=newDiv;holder.innerHTML=""}return holder}else{return null}},render:function(container){var me=this,options=me.options,getStyleValue=function(attr){return parseInt($(container).css(attr))};if(utils.isString(container)){container=document.getElementById(container)}if(container){this.id=container.getAttribute("id");UM.setEditor(this);utils.cssRule("edui-style-body",me.options.initialStyle,document);container=this.initialCont(container);container.className+=" edui-body-container";if(options.initialFrameWidth){options.minFrameWidth=options.initialFrameWidth}else{options.minFrameWidth=options.initialFrameWidth=$(container).width()||UM.defaultWidth}if(options.initialFrameHeight){options.minFrameHeight=options.initialFrameHeight}else{options.initialFrameHeight=options.minFrameHeight=$(container).height()||UM.defaultHeight}container.style.width=/%$/.test(options.initialFrameWidth)?"100%":options.initialFrameWidth-getStyleValue("padding-left")-getStyleValue("padding-right")+"px";var height=/%$/.test(options.initialFrameHeight)?"100%":options.initialFrameHeight-getStyleValue("padding-top")-getStyleValue("padding-bottom");if(this.options.autoHeightEnabled){container.style.minHeight=height+"px";container.style.height="";if(browser.ie&&browser.version<=6){container.style.height=height;container.style.setExpression("height","this.scrollHeight <= "+height+' ? "'+height+'px" : "auto"')}}else{$(container).height(height)}container.style.zIndex=options.zIndex;this._setup(container)}},_setup:function(cont){var me=this,options=me.options;cont.contentEditable=true;document.body.spellcheck=false;me.document=document;me.window=document.defaultView||document.parentWindow;me.body=cont;me.$body=$(cont);me.selection=new dom.Selection(document,me.body);me._isEnabled=false;var geckoSel;if(browser.gecko&&(geckoSel=this.selection.getNative())){geckoSel.removeAllRanges()}this._initEvents();for(var form=cont.parentNode;form&&!domUtils.isBody(form);form=form.parentNode){if(form.tagName=="FORM"){me.form=form;if(me.options.autoSyncData){$(cont).on("blur",function(){setValue(form,me)})}else{$(form).on("submit",function(){setValue(this,me)})}break}}if(options.initialContent){if(options.autoClearinitialContent){var oldExecCommand=me.execCommand;me.execCommand=function(){me.fireEvent("firstBeforeExecCommand");return oldExecCommand.apply(me,arguments)};this._setDefaultContent(options.initialContent)}else this.setContent(options.initialContent,false,true)}if(domUtils.isEmptyNode(me.body)){me.body.innerHTML="

"+(browser.ie?"":"
")+"

"}if(options.focus){setTimeout(function(){me.focus(me.options.focusInEnd);!me.options.autoClearinitialContent&&me._selectionChange()},0)}if(!me.container){me.container=cont.parentNode}me._bindshortcutKeys();me.isReady=1;me.fireEvent("ready");options.onready&&options.onready.call(me);if(!browser.ie||browser.ie9above){$(me.body).on("blur focus",function(e){var nSel=me.selection.getNative();if(e.type=="blur"){if(nSel.rangeCount>0){me._bakRange=nSel.getRangeAt(0)}}else{try{me._bakRange&&nSel.addRange(me._bakRange)}catch(e){}me._bakRange=null}})}!options.isShow&&me.setHide();options.readonly&&me.setDisabled()},sync:function(formId){var me=this,form=formId?document.getElementById(formId):domUtils.findParent(me.body.parentNode,function(node){return node.tagName=="FORM"},true);form&&setValue(form,me)},setHeight:function(height,notSetHeight){!notSetHeight&&(this.options.initialFrameHeight=height);if(this.options.autoHeightEnabled){$(this.body).css({"min-height":height+"px"});if(browser.ie&&browser.version<=6&&this.container){this.container.style.height=height;this.container.style.setExpression("height","this.scrollHeight <= "+height+' ? "'+height+'px" : "auto"')}}else{$(this.body).height(height)}this.fireEvent("resize")},setWidth:function(width){this.$container&&this.$container.width(width);$(this.body).width(width-$(this.body).css("padding-left").replace("px","")*1-$(this.body).css("padding-right").replace("px","")*1);this.fireEvent("resize")},addshortcutkey:function(cmd,keys){var obj={};if(keys){obj[cmd]=keys}else{obj=cmd}utils.extend(this.shortcutkeys,obj)},_bindshortcutKeys:function(){var me=this,shortcutkeys=this.shortcutkeys;me.addListener("keydown",function(type,e){var keyCode=e.keyCode||e.which;for(var i in shortcutkeys){var tmp=shortcutkeys[i].split(",");for(var t=0,ti;ti=tmp[t++];){ti=ti.split(":");var key=ti[0],param=ti[1];if(/^(ctrl)(\+shift)?\+(\d+)$/.test(key.toLowerCase())||/^(\d+)$/.test(key)){if((RegExp.$1=="ctrl"?e.ctrlKey||e.metaKey:0)&&(RegExp.$2!=""?e[RegExp.$2.slice(1)+"Key"]:1)&&keyCode==RegExp.$3||keyCode==RegExp.$1){if(me.queryCommandState(i,param)!=-1)me.execCommand(i,param);domUtils.preventDefault(e)}}}}})},getContent:function(cmd,fn,notSetCursor,ignoreBlank,formatter){var me=this;if(cmd&&utils.isFunction(cmd)){fn=cmd;cmd=""}if(fn?!fn():!this.hasContents()){return""}me.fireEvent("beforegetcontent");var root=UM.htmlparser(me.body.innerHTML,ignoreBlank);me.filterOutputRule(root);me.fireEvent("aftergetcontent",root);return root.toHtml(formatter)},getAllHtml:function(){var me=this,headHtml=[],html="";me.fireEvent("getAllHtml",headHtml);if(browser.ie&&browser.version>8){var headHtmlForIE9="";utils.each(me.document.styleSheets,function(si){headHtmlForIE9+=si.href?'':""});utils.each(me.document.getElementsByTagName("script"),function(si){headHtmlForIE9+=si.outerHTML})}return""+(me.options.charset?'':"")+(headHtmlForIE9||me.document.getElementsByTagName("head")[0].innerHTML)+headHtml.join("\n")+""+""+me.getContent(null,null,true)+""},getPlainTxt:function(){var reg=new RegExp(domUtils.fillChar,"g"),html=this.body.innerHTML.replace(/[\n\r]/g,"");html=html.replace(/<(p|div)[^>]*>(| )<\/\1>/gi,"\n").replace(//gi,"\n").replace(/<[^>/]+>/g,"").replace(/(\n)?<\/([^>]+)>/g,function(a,b,c){return dtd.$block[c]?"\n":b?b:""});return html.replace(reg,"").replace(/\u00a0/g," ").replace(/ /g," ")},getContentTxt:function(){var reg=new RegExp(domUtils.fillChar,"g");return this.body[browser.ie?"innerText":"textContent"].replace(reg,"").replace(/\u00a0/g," ")},setContent:function(html,isAppendTo,notFireSelectionchange){var me=this;me.fireEvent("beforesetcontent",html);var root=UM.htmlparser(html);me.filterInputRule(root);html=root.toHtml();me.body.innerHTML=(isAppendTo?me.body.innerHTML:"")+html;function isCdataDiv(node){return node.tagName=="DIV"&&node.getAttribute("cdata_tag")}if(me.options.enterTag=="p"){var child=this.body.firstChild,tmpNode;if(!child||child.nodeType==1&&(dtd.$cdata[child.tagName]||isCdataDiv(child)||domUtils.isCustomeNode(child))&&child===this.body.lastChild){this.body.innerHTML="

"+(browser.ie?" ":"
")+"

"+this.body.innerHTML}else{var p=me.document.createElement("p");while(child){while(child&&(child.nodeType==3||child.nodeType==1&&dtd.p[child.tagName]&&!dtd.$cdata[child.tagName])){tmpNode=child.nextSibling;p.appendChild(child);child=tmpNode}if(p.firstChild){if(!child){me.body.appendChild(p);break}else{child.parentNode.insertBefore(p,child);p=me.document.createElement("p")}}child=child.nextSibling}}}me.fireEvent("aftersetcontent");me.fireEvent("contentchange");!notFireSelectionchange&&me._selectionChange();me._bakRange=me._bakIERange=me._bakNativeRange=null;var geckoSel;if(browser.gecko&&(geckoSel=this.selection.getNative())){geckoSel.removeAllRanges()}if(me.options.autoSyncData){me.form&&setValue(me.form,me)}},focus:function(toEnd){try{var me=this,rng=me.selection.getRange();if(toEnd){rng.setStartAtLast(me.body.lastChild).setCursor(false,true)}else{rng.select(true)}this.fireEvent("focus")}catch(e){}},blur:function(){var sel=this.selection.getNative();sel.empty?sel.empty():sel.removeAllRanges();this.fireEvent("blur")},isFocus:function(){if(this.fireEvent("isfocus")===true){return true}return this.selection.isFocus()},_initEvents:function(){var me=this,cont=me.body,_proxyDomEvent=function(){me._proxyDomEvent.apply(me,arguments)};$(cont).on("click contextmenu mousedown keydown keyup keypress mouseup mouseover mouseout selectstart",_proxyDomEvent).on("focus blur",_proxyDomEvent).on("mouseup keydown",function(evt){if(evt.type=="keydown"&&(evt.ctrlKey||evt.metaKey||evt.shiftKey||evt.altKey)){return}if(evt.button==2)return;me._selectionChange(250,evt)})},_proxyDomEvent:function(evt){return this.fireEvent(evt.type.replace(/^on/,""),evt)},_selectionChange:function(delay,evt){var me=this;var hackForMouseUp=false;var mouseX,mouseY;if(browser.ie&&browser.version<9&&evt&&evt.type=="mouseup"){var range=this.selection.getRange();if(!range.collapsed){hackForMouseUp=true;mouseX=evt.clientX;mouseY=evt.clientY}}clearTimeout(_selectionChangeTimer);_selectionChangeTimer=setTimeout(function(){if(!me.selection.getNative()){return}var ieRange;if(hackForMouseUp&&me.selection.getNative().type=="None"){ieRange=me.document.body.createTextRange();try{ieRange.moveToPoint(mouseX,mouseY)}catch(ex){ieRange=null}}var bakGetIERange;if(ieRange){bakGetIERange=me.selection.getIERange;me.selection.getIERange=function(){return ieRange}}me.selection.cache();if(bakGetIERange){me.selection.getIERange=bakGetIERange}if(me.selection._cachedRange&&me.selection._cachedStartElement){me.fireEvent("beforeselectionchange");me.fireEvent("selectionchange",!!evt);me.fireEvent("afterselectionchange");me.selection.clear()}},delay||50)},_callCmdFn:function(fnName,args){args=Array.prototype.slice.call(args,0);var cmdName=args.shift().toLowerCase(),cmd,cmdFn;cmd=this.commands[cmdName]||UM.commands[cmdName];cmdFn=cmd&&cmd[fnName];if((!cmd||!cmdFn)&&fnName=="queryCommandState"){return 0}else if(cmdFn){return cmdFn.apply(this,[cmdName].concat(args))}},execCommand:function(cmdName){if(!this.isFocus()){var bakRange=this.selection._bakRange;if(bakRange){bakRange.select()}else{this.focus(true)}}cmdName=cmdName.toLowerCase();var me=this,result,cmd=me.commands[cmdName]||UM.commands[cmdName];if(!cmd||!cmd.execCommand){return null}if(!cmd.notNeedUndo&&!me.__hasEnterExecCommand){me.__hasEnterExecCommand=true;if(me.queryCommandState.apply(me,arguments)!=-1){me.fireEvent("saveScene");me.fireEvent("beforeexeccommand",cmdName);result=this._callCmdFn("execCommand",arguments);!cmd.ignoreContentChange&&!me._ignoreContentChange&&me.fireEvent("contentchange");me.fireEvent("afterexeccommand",cmdName);me.fireEvent("saveScene")}me.__hasEnterExecCommand=false}else{result=this._callCmdFn("execCommand",arguments);!me.__hasEnterExecCommand&&!cmd.ignoreContentChange&&!me._ignoreContentChange&&me.fireEvent("contentchange")}!me.__hasEnterExecCommand&&!cmd.ignoreContentChange&&!me._ignoreContentChange&&me._selectionChange();return result},queryCommandState:function(cmdName){try{return this._callCmdFn("queryCommandState",arguments)}catch(e){return 0}},queryCommandValue:function(cmdName){try{return this._callCmdFn("queryCommandValue",arguments)}catch(e){return null}},hasContents:function(tags){if(tags){for(var i=0,ci;ci=tags[i++];){if(this.body.getElementsByTagName(ci).length>0){return true}}}if(!domUtils.isEmptyBlock(this.body)){return true}tags=["div"];for(i=0;ci=tags[i++];){var nodes=domUtils.getElementsByTagName(this.body,ci);for(var n=0,cn;cn=nodes[n++];){if(domUtils.isCustomeNode(cn)){return true}}}return false},reset:function(){this.fireEvent("reset")},isEnabled:function(){return this._isEnabled!=true},setEnabled:function(){var me=this,range;me.body.contentEditable=true;if(me.lastBk){range=me.selection.getRange();try{range.moveToBookmark(me.lastBk);delete me.lastBk}catch(e){range.setStartAtFirst(me.body).collapse(true)}range.select(true)}if(me.bkqueryCommandState){me.queryCommandState=me.bkqueryCommandState;delete me.bkqueryCommandState}if(me._bkproxyDomEvent){me._proxyDomEvent=me._bkproxyDomEvent;delete me._bkproxyDomEvent}me.fireEvent("setEnabled")},enable:function(){return this.setEnabled()},setDisabled:function(except,keepDomEvent){var me=this;me.body.contentEditable=false;me._except=except?utils.isArray(except)?except:[except]:[];if(!me.lastBk){me.lastBk=me.selection.getRange().createBookmark(true)}if(!me.bkqueryCommandState){me.bkqueryCommandState=me.queryCommandState;me.queryCommandState=function(type){if(utils.indexOf(me._except,type)!=-1){return me.bkqueryCommandState.apply(me,arguments)}return-1}}if(!keepDomEvent&&!me._bkproxyDomEvent){me._bkproxyDomEvent=me._proxyDomEvent;me._proxyDomEvent=function(){return false}}me.fireEvent("selectionchange");me.fireEvent("setDisabled",me._except)},disable:function(except){return this.setDisabled(except)},_setDefaultContent:function(){function clear(){var me=this;if(me.document.getElementById("initContent")){me.body.innerHTML="

"+(ie?"":"
")+"

";me.removeListener("firstBeforeExecCommand focus",clear);setTimeout(function(){me.focus();me._selectionChange()},0)}}return function(cont){var me=this;me.body.innerHTML='

'+cont+"

";me.addListener("firstBeforeExecCommand focus",clear)}}(),setShow:function(){var me=this,range=me.selection.getRange();if(me.container.style.display=="none"){try{range.moveToBookmark(me.lastBk);delete me.lastBk}catch(e){range.setStartAtFirst(me.body).collapse(true)}setTimeout(function(){range.select(true)},100);me.container.style.display=""}},show:function(){return this.setShow()},setHide:function(){var me=this;if(!me.lastBk){me.lastBk=me.selection.getRange().createBookmark(true)}me.container.style.display="none"},hide:function(){return this.setHide()},getLang:function(path){var lang=UM.I18N[this.options.lang];if(!lang){throw Error("not import language file")}path=(path||"").split(".");for(var i=0,ci;ci=path[i++];){lang=lang[ci];if(!lang)break}return lang},getContentLength:function(ingoneHtml,tagNames){var count=this.getContent(false,false,true).length;if(ingoneHtml){tagNames=(tagNames||[]).concat(["hr","img","iframe"]);count=this.getContentTxt().replace(/[\t\r\n]+/g,"").length;for(var i=0,ci;ci=tagNames[i++];){count+=this.body.getElementsByTagName(ci).length}}return count},addInputRule:function(rule,ignoreUndo){rule.ignoreUndo=ignoreUndo;this.inputRules.push(rule)},filterInputRule:function(root,isUndoLoad){for(var i=0,ci;ci=this.inputRules[i++];){if(isUndoLoad&&ci.ignoreUndo){continue}ci.call(this,root)}},addOutputRule:function(rule,ignoreUndo){rule.ignoreUndo=ignoreUndo;this.outputRules.push(rule)},filterOutputRule:function(root,isUndoLoad){for(var i=0,ci;ci=this.outputRules[i++];){if(isUndoLoad&&ci.ignoreUndo){continue}ci.call(this,root)}}};utils.inherits(Editor,EventBase)})();var filterWord=UM.filterWord=function(){function isWordDocument(str){return/(class="?Mso|style="[^"]*\bmso\-|w:WordDocument|<(v|o):|lang=)/gi.test(str)}function transUnit(v){v=v.replace(/[\d.]+\w+/g,function(m){return utils.transUnitToPx(m)});return v}function filterPasteWord(str){return str.replace(/[\t\r\n]+/g," ").replace(//gi,"").replace(/]*>[\s\S]*?.<\/v:shape>/gi,function(str){if(browser.opera){return""}try{if(/Bitmap/i.test(str)){return""}var width=str.match(/width:([ \d.]*p[tx])/i)[1],height=str.match(/height:([ \d.]*p[tx])/i)[1],src=str.match(/src=\s*"([^"]*)"/i)[1];return''}catch(e){return""}}).replace(/<\/?div[^>]*>/g,"").replace(/v:\w+=(["']?)[^'"]+\1/g,"").replace(/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|xml|meta|link|style|\w+:\w+)(?=[\s\/>]))[^>]*>/gi,"").replace(/

]*class="?MsoHeading"?[^>]*>(.*?)<\/p>/gi,"

$1

").replace(/\s+(class|lang|align)\s*=\s*(['"]?)([\w-]+)\2/gi,function(str,name,marks,val){return name=="class"&&val=="MsoListParagraph"?str:""}).replace(/<(font|span)[^>]*>(\s*)<\/\1>/gi,function(a,b,c){return c.replace(/[\t\r\n ]+/g," ")}).replace(/(<[a-z][^>]*)\sstyle=(["'])([^\2]*?)\2/gi,function(str,tag,tmp,style){var n=[],s=style.replace(/^\s+|\s+$/,"").replace(/'/g,"'").replace(/"/gi,"'").split(/;\s*/g);for(var i=0,v;v=s[i];i++){var name,value,parts=v.split(":");if(parts.length==2){name=parts[0].toLowerCase();value=parts[1].toLowerCase();if(/^(background)\w*/.test(name)&&value.replace(/(initial|\s)/g,"").length==0||/^(margin)\w*/.test(name)&&/^0\w+$/.test(value)){continue}switch(name){case"mso-padding-alt":case"mso-padding-top-alt":case"mso-padding-right-alt":case"mso-padding-bottom-alt":case"mso-padding-left-alt":case"mso-margin-alt":case"mso-margin-top-alt":case"mso-margin-right-alt":case"mso-margin-bottom-alt":case"mso-margin-left-alt":case"mso-height":case"mso-width":case"mso-vertical-align-alt":if(!/]/.test(html)){return UM.htmlparser(html).children[0]}else{return new uNode({type:"element",children:[],tagName:html})}};uNode.createText=function(data,noTrans){return new UM.uNode({type:"text",data:noTrans?data:utils.unhtml(data||"")})};function nodeToHtml(node,arr,formatter,current){switch(node.type){case"root":for(var i=0,ci;ci=node.children[i++];){if(formatter&&ci.type=="element"&&!dtd.$inlineWithA[ci.tagName]&&i>1){insertLine(arr,current,true);insertIndent(arr,current)}nodeToHtml(ci,arr,formatter,current)}break;case"text":isText(node,arr);break;case"element":isElement(node,arr,formatter,current);break;case"comment":isComment(node,arr,formatter)}return arr}function isText(node,arr){if(node.parentNode.tagName=="pre"){arr.push(node.data)}else{arr.push(notTransTagName[node.parentNode.tagName]?utils.html(node.data):node.data.replace(/[ ]{2}/g," "))}}function isElement(node,arr,formatter,current){var attrhtml="";if(node.attrs){attrhtml=[];var attrs=node.attrs;for(var a in attrs){attrhtml.push(a+(attrs[a]!==undefined?'="'+(notTransAttrs[a]?utils.html(attrs[a]).replace(/["]/g,function(a){return"""}):utils.unhtml(attrs[a]))+'"':""))}attrhtml=attrhtml.join(" ")}arr.push("<"+node.tagName+(attrhtml?" "+attrhtml:"")+(dtd.$empty[node.tagName]?"/":"")+">");if(formatter&&!dtd.$inlineWithA[node.tagName]&&node.tagName!="pre"){if(node.children&&node.children.length){current=insertLine(arr,current,true);insertIndent(arr,current)}}if(node.children&&node.children.length){for(var i=0,ci;ci=node.children[i++];){if(formatter&&ci.type=="element"&&!dtd.$inlineWithA[ci.tagName]&&i>1){insertLine(arr,current);insertIndent(arr,current)}nodeToHtml(ci,arr,formatter,current)}}if(!dtd.$empty[node.tagName]){if(formatter&&!dtd.$inlineWithA[node.tagName]&&node.tagName!="pre"){if(node.children&&node.children.length){current=insertLine(arr,current);insertIndent(arr,current)}}arr.push("")}}function isComment(node,arr){arr.push("\x3c!--"+node.data+"--\x3e")}function getNodeById(root,id){var node;if(root.type=="element"&&root.getAttr("id")==id){return root}if(root.children&&root.children.length){for(var i=0,ci;ci=root.children[i++];){if(node=getNodeById(ci,id)){return node}}}}function getNodesByTagName(node,tagName,arr){if(node.type=="element"&&node.tagName==tagName){arr.push(node)}if(node.children&&node.children.length){for(var i=0,ci;ci=node.children[i++];){getNodesByTagName(ci,tagName,arr)}}}function nodeTraversal(root,fn){if(root.children&&root.children.length){for(var i=0,ci;ci=root.children[i];){nodeTraversal(ci,fn);if(ci.parentNode){if(ci.children&&ci.children.length){fn(ci)}if(ci.parentNode)i++}}}else{fn(root)}}uNode.prototype={toHtml:function(formatter){var arr=[];nodeToHtml(this,arr,formatter,0);return arr.join("")},innerHTML:function(htmlstr){if(this.type!="element"||dtd.$empty[this.tagName]){return this}if(utils.isString(htmlstr)){if(this.children){for(var i=0,ci;ci=this.children[i++];){ci.parentNode=null}}this.children=[];var tmpRoot=UM.htmlparser(htmlstr);for(var i=0,ci;ci=tmpRoot.children[i++];){this.children.push(ci);ci.parentNode=this}return this}else{var tmpRoot=new UM.uNode({type:"root",children:this.children});return tmpRoot.toHtml()}},innerText:function(textStr,noTrans){if(this.type!="element"||dtd.$empty[this.tagName]){return this}if(textStr){if(this.children){for(var i=0,ci;ci=this.children[i++];){ci.parentNode=null}}this.children=[];this.appendChild(uNode.createText(textStr,noTrans));return this}else{return this.toHtml().replace(/<[^>]+>/g,"")}},getData:function(){if(this.type=="element")return"";return this.data},firstChild:function(){return this.children?this.children[0]:null},lastChild:function(){return this.children?this.children[this.children.length-1]:null},previousSibling:function(){var parent=this.parentNode;for(var i=0,ci;ci=parent.children[i];i++){if(ci===this){return i==0?null:parent.children[i-1]}}},nextSibling:function(){var parent=this.parentNode;for(var i=0,ci;ci=parent.children[i++];){if(ci===this){return parent.children[i]}}},replaceChild:function(target,source){if(this.children){if(target.parentNode){target.parentNode.removeChild(target)}for(var i=0,ci;ci=this.children[i];i++){if(ci===source){this.children.splice(i,1,target);source.parentNode=null;target.parentNode=this;return target}}}},appendChild:function(node){if(this.type=="root"||this.type=="element"&&!dtd.$empty[this.tagName]){if(!this.children){this.children=[]}if(node.parentNode){node.parentNode.removeChild(node)}for(var i=0,ci;ci=this.children[i];i++){if(ci===node){this.children.splice(i,1);break}}this.children.push(node);node.parentNode=this;return node}},insertBefore:function(target,source){if(this.children){if(target.parentNode){target.parentNode.removeChild(target)}for(var i=0,ci;ci=this.children[i];i++){if(ci===source){this.children.splice(i,0,target);target.parentNode=this;return target}}}},insertAfter:function(target,source){if(this.children){if(target.parentNode){target.parentNode.removeChild(target)}for(var i=0,ci;ci=this.children[i];i++){if(ci===source){this.children.splice(i+1,0,target);target.parentNode=this;return target}}}},removeChild:function(node,keepChildren){if(this.children){for(var i=0,ci;ci=this.children[i];i++){if(ci===node){this.children.splice(i,1);ci.parentNode=null;if(keepChildren&&ci.children&&ci.children.length){for(var j=0,cj;cj=ci.children[j];j++){this.children.splice(i+j,0,cj);cj.parentNode=this}}return ci}}}},getAttr:function(attrName){return this.attrs&&this.attrs[attrName.toLowerCase()]},setAttr:function(attrName,attrVal){if(!attrName){delete this.attrs;return}if(!this.attrs){this.attrs={}}if(utils.isObject(attrName)){for(var a in attrName){if(!attrName[a]){delete this.attrs[a]}else{this.attrs[a.toLowerCase()]=attrName[a]}}}else{if(!attrVal){delete this.attrs[attrName]}else{this.attrs[attrName.toLowerCase()]=attrVal}}},hasAttr:function(attrName){var attrVal=this.getAttr(attrName);return attrVal!==null&&attrVal!==undefined},getIndex:function(){var parent=this.parentNode;for(var i=0,ci;ci=parent.children[i];i++){if(ci===this){return i}}return-1},getNodeById:function(id){var node;if(this.children&&this.children.length){for(var i=0,ci;ci=this.children[i++];){if(node=getNodeById(ci,id)){return node}}}},getNodesByTagName:function(tagNames){tagNames=utils.trim(tagNames).replace(/[ ]{2,}/g," ").split(" ");var arr=[],me=this;utils.each(tagNames,function(tagName){if(me.children&&me.children.length){for(var i=0,ci;ci=me.children[i++];){getNodesByTagName(ci,tagName,arr)}}});return arr},getStyle:function(name){var cssStyle=this.getAttr("style");if(!cssStyle){return""}var reg=new RegExp("(^|;)\\s*"+name+":([^;]+)","i");var match=cssStyle.match(reg);if(match&&match[0]){return match[2]}return""},setStyle:function(name,val){function exec(name,val){var reg=new RegExp("(^|;)\\s*"+name+":([^;]+;?)","gi");cssStyle=cssStyle.replace(reg,"$1");if(val){cssStyle=name+":"+utils.unhtml(val)+";"+cssStyle}}var cssStyle=this.getAttr("style");if(!cssStyle){cssStyle=""}if(utils.isObject(name)){for(var a in name){exec(a,name[a])}}else{exec(name,val)}this.setAttr("style",utils.trim(cssStyle))},hasClass:function(className){if(this.hasAttr("class")){var classNames=this.getAttr("class").split(/\s+/),hasClass=false;$.each(classNames,function(key,item){if(item===className){hasClass=true}});return hasClass}else{return false}},addClass:function(className){var classes=null,hasClass=false;if(this.hasAttr("class")){classes=this.getAttr("class");classes=classes.split(/\s+/);classes.forEach(function(item){if(item===className){hasClass=true;return}});!hasClass&&classes.push(className);this.setAttr("class",classes.join(" "))}else{this.setAttr("class",className)}},removeClass:function(className){if(this.hasAttr("class")){var cl=this.getAttr("class");cl=cl.replace(new RegExp("\\b"+className+"\\b","g"),"");this.setAttr("class",utils.trim(cl).replace(/[ ]{2,}/g," "))}},traversal:function(fn){if(this.children&&this.children.length){nodeTraversal(this,fn)}return this}}})();var htmlparser=UM.htmlparser=function(htmlstr,ignoreBlank){var re_tag=/<(?:(?:\/([^>]+)>)|(?:!--([\S|\s]*?)-->)|(?:([^\s\/>]+)\s*((?:(?:"[^"]*")|(?:'[^']*')|[^"'<>])*)\/?>))/g,re_attr=/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g;var allowEmptyTags={b:1,code:1,i:1,u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,span:1,sub:1,img:1,sup:1,font:1,big:1,small:1,iframe:1,a:1,br:1,pre:1};htmlstr=htmlstr.replace(new RegExp(domUtils.fillChar,"g"),"");if(!ignoreBlank){htmlstr=htmlstr.replace(new RegExp("[\\r\\t\\n"+(ignoreBlank?"":" ")+"]*]*)>[\\r\\t\\n"+(ignoreBlank?"":" ")+"]*","g"),function(a,b){if(b&&allowEmptyTags[b.toLowerCase()]){return a.replace(/(^[\n\r]+)|([\n\r]+$)/g,"")}return a.replace(new RegExp("^[\\r\\n"+(ignoreBlank?"":" ")+"]+"),"").replace(new RegExp("[\\r\\n"+(ignoreBlank?"":" ")+"]+$"),"")})}var notTransAttrs={href:1,src:1};var uNode=UM.uNode,needParentNode={td:"tr",tr:["tbody","thead","tfoot"],tbody:"table",th:"tr",thead:"table",tfoot:"table",caption:"table",li:["ul","ol"],dt:"dl",dd:"dl",option:"select"},needChild={ol:"li",ul:"li"};function text(parent,data){if(needChild[parent.tagName]){var tmpNode=uNode.createElement(needChild[parent.tagName]);parent.appendChild(tmpNode);tmpNode.appendChild(uNode.createText(data));parent=tmpNode}else{parent.appendChild(uNode.createText(data))}}function element(parent,tagName,htmlattr){var needParentTag;if(needParentTag=needParentNode[tagName]){var tmpParent=parent,hasParent;while(tmpParent.type!="root"){if(utils.isArray(needParentTag)?utils.indexOf(needParentTag,tmpParent.tagName)!=-1:needParentTag==tmpParent.tagName){parent=tmpParent;hasParent=true;break}tmpParent=tmpParent.parentNode}if(!hasParent){parent=element(parent,utils.isArray(needParentTag)?needParentTag[0]:needParentTag)}}var elm=new uNode({parentNode:parent,type:"element",tagName:tagName.toLowerCase(),children:dtd.$empty[tagName]?null:[]});if(htmlattr){var attrs={},match;while(match=re_attr.exec(htmlattr)){attrs[match[1].toLowerCase()]=notTransAttrs[match[1].toLowerCase()]?match[2]||match[3]||match[4]:utils.unhtml(match[2]||match[3]||match[4])}elm.attrs=attrs}parent.children.push(elm);return dtd.$empty[tagName]?parent:elm}function comment(parent,data){parent.children.push(new uNode({type:"comment",data:data,parentNode:parent}))}var match,currentIndex=0,nextIndex=0;var root=new uNode({type:"root",children:[]});var currentParent=root;while(match=re_tag.exec(htmlstr)){currentIndex=match.index;try{if(currentIndex>nextIndex){text(currentParent,htmlstr.slice(nextIndex,currentIndex))}if(match[3]){if(dtd.$cdata[currentParent.tagName]){text(currentParent,match[0])}else{currentParent=element(currentParent,match[3].toLowerCase(),match[4])}}else if(match[1]){if(currentParent.type!="root"){if(dtd.$cdata[currentParent.tagName]&&!dtd.$cdata[match[1]]){text(currentParent,match[0])}else{var tmpParent=currentParent;while(currentParent.type=="element"&¤tParent.tagName!=match[1].toLowerCase()){currentParent=currentParent.parentNode;if(currentParent.type=="root"){currentParent=tmpParent;throw"break"}}currentParent=currentParent.parentNode}}}else if(match[2]){comment(currentParent,match[2])}}catch(e){}nextIndex=re_tag.lastIndex}if(nextIndex"+(browser.ie?"":"
")+"

";range.setStart(me.body.firstChild,0).collapse(true)}}}!range.collapsed&&range.deleteContents();if(range.startContainer.nodeType==1){var child=range.startContainer.childNodes[range.startOffset],pre;if(child&&domUtils.isBlockElm(child)&&(pre=child.previousSibling)&&domUtils.isBlockElm(pre)){range.setEnd(pre,pre.childNodes.length).collapse();while(child.firstChild){pre.appendChild(child.firstChild)}domUtils.remove(child)}}}var child,parent,pre,tmp,hadBreak=0,nextNode;if(range.inFillChar()){child=range.startContainer;if(domUtils.isFillChar(child)){range.setStartBefore(child).collapse(true);domUtils.remove(child)}else if(domUtils.isFillChar(child,true)){child.nodeValue=child.nodeValue.replace(fillCharReg,"");range.startOffset--;range.collapsed&&range.collapse(true)}}while(child=div.firstChild){if(hadBreak){var p=me.document.createElement("p");while(child&&(child.nodeType==3||!dtd.$block[child.tagName])){nextNode=child.nextSibling;p.appendChild(child);child=nextNode}if(p.firstChild){child=p}}range.insertNode(child);nextNode=child.nextSibling;if(!hadBreak&&child.nodeType==domUtils.NODE_ELEMENT&&domUtils.isBlockElm(child)){parent=domUtils.findParent(child,function(node){return domUtils.isBlockElm(node)});if(parent&&parent.tagName.toLowerCase()!="body"&&!(dtd[parent.tagName][child.nodeName]&&child.parentNode===parent)){if(!dtd[parent.tagName][child.nodeName]){pre=parent}else{tmp=child.parentNode;while(tmp!==parent){pre=tmp;tmp=tmp.parentNode}}domUtils.breakParent(child,pre||tmp);var pre=child.previousSibling;domUtils.trimWhiteTextNode(pre);if(!pre.childNodes.length){domUtils.remove(pre)}if(!browser.ie&&(next=child.nextSibling)&&domUtils.isBlockElm(next)&&next.lastChild&&!domUtils.isBr(next.lastChild)){next.appendChild(me.document.createElement("br"))}hadBreak=1}}var next=child.nextSibling;if(!div.firstChild&&next&&domUtils.isBlockElm(next)){range.setStart(next,0).collapse(true);break}range.setEndAfter(child).collapse()}child=range.startContainer;if(nextNode&&domUtils.isBr(nextNode)){domUtils.remove(nextNode)}if(domUtils.isBlockElm(child)&&domUtils.isEmptyNode(child)){if(nextNode=child.nextSibling){domUtils.remove(child);if(nextNode.nodeType==1&&dtd.$block[nextNode.tagName]){range.setStart(nextNode,0).collapse(true).shrinkBoundary()}}else{try{child.innerHTML=browser.ie?domUtils.fillChar:"
"}catch(e){range.setStartBefore(child);domUtils.remove(child)}}}try{if(browser.ie9below&&range.startContainer.nodeType==1&&!range.startContainer.childNodes[range.startOffset]){var start=range.startContainer,pre=start.childNodes[range.startOffset-1];if(pre&&pre.nodeType==1&&dtd.$empty[pre.tagName]){var txt=this.document.createTextNode(domUtils.fillChar);range.insertNode(txt).setStart(txt,0).collapse(true)}}setTimeout(function(){range.select(true)})}catch(e){}setTimeout(function(){range=me.selection.getRange();range.scrollIntoView();me.fireEvent("afterinserthtml")},200)}};UM.commands["insertimage"]={execCommand:function(cmd,opt){opt=utils.isArray(opt)?opt:[opt];if(!opt.length){return}var me=this;var html=[],str="",ci;ci=opt[0];if(opt.length==1){str=''+ci.alt+'";if(ci["floatStyle"]=="center"){str='

'+str+"

"}html.push(str)}else{for(var i=0;ci=opt[i++];){str="

";html.push(str)}}me.execCommand("insertHtml",html.join(""),true)}};UM.plugins["justify"]=function(){var me=this;$.each("justifyleft justifyright justifycenter justifyfull".split(" "),function(i,cmdName){me.commands[cmdName]={execCommand:function(cmdName){return this.document.execCommand(cmdName)},queryCommandValue:function(cmdName){var val=this.document.queryCommandValue(cmdName);return val===true||val==="true"?cmdName.replace(/justify/,""):""},queryCommandState:function(cmdName){return this.document.queryCommandState(cmdName)?1:0}}})};UM.plugins["font"]=function(){var me=this,fonts={forecolor:"forecolor",backcolor:"backcolor",fontsize:"fontsize",fontfamily:"fontname"},cmdNameToStyle={forecolor:"color",backcolor:"background-color",fontsize:"font-size",fontfamily:"font-family"},cmdNameToAttr={forecolor:"color",fontsize:"size",fontfamily:"face"};me.setOpt({fontfamily:[{name:"songti",val:"宋体,SimSun"},{name:"yahei",val:"微软雅黑,Microsoft YaHei"},{name:"kaiti",val:"楷体,楷体_GB2312, SimKai"},{name:"heiti",val:"黑体, SimHei"},{name:"lishu",val:"隶书, SimLi"},{name:"andaleMono",val:"andale mono"},{name:"arial",val:"arial, helvetica,sans-serif"},{name:"arialBlack",val:"arial black,avant garde"},{name:"comicSansMs",val:"comic sans ms"},{name:"impact",val:"impact,chicago"},{name:"timesNewRoman",val:"times new roman"},{name:"sans-serif",val:"sans-serif"}],fontsize:[12,14,16,18,24,32,48]});me.addOutputRule(function(root){utils.each(root.getNodesByTagName("font"),function(node){if(node.tagName=="font"){var cssStyle=[];for(var p in node.attrs){switch(p){case"size":var val=node.attrs[p];$.each({12:"1",14:"2",16:"3",18:"4",24:"5",32:"6",48:"7"},function(k,v){if(v==val){val=k;return false}});cssStyle.push("font-size:"+val+"px");break;case"color":cssStyle.push("color:"+node.attrs[p]);break;case"face":cssStyle.push("font-family:"+node.attrs[p]);break;case"style":cssStyle.push(node.attrs[p])}}node.attrs={style:cssStyle.join(";")}}node.tagName="span";if(node.parentNode.tagName=="span"&&node.parentNode.children.length==1){$.each(node.attrs,function(k,v){node.parentNode.attrs[k]=k=="style"?node.parentNode.attrs[k]+v:v});node.parentNode.removeChild(node,true)}})});for(var p in fonts){(function(cmd){me.commands[cmd]={execCommand:function(cmdName,value){if(value=="transparent"){return}var rng=this.selection.getRange();if(rng.collapsed){var span=$("").css(cmdNameToStyle[cmdName],value)[0];rng.insertNode(span).setStart(span,0).setCursor()}else{if(cmdName=="fontsize"){value={12:"1",14:"2",16:"3",18:"4",24:"5",32:"6",48:"7"}[(value+"").replace(/px/,"")]}this.document.execCommand(fonts[cmdName],false,value);if(browser.gecko){$.each(this.$body.find("a"),function(i,a){var parent=a.parentNode;if(parent.lastChild===parent.firstChild&&/FONT|SPAN/.test(parent.tagName)){var cloneNode=parent.cloneNode(false);cloneNode.innerHTML=a.innerHTML;$(a).html("").append(cloneNode).insertBefore(parent);$(parent).remove()}})}if(!browser.ie){var nativeRange=this.selection.getNative().getRangeAt(0);var common=nativeRange.commonAncestorContainer;var rng=this.selection.getRange(),bk=rng.createBookmark(true);$(common).find("a").each(function(i,n){var parent=n.parentNode;if(parent.nodeName=="FONT"){var font=parent.cloneNode(false);font.innerHTML=n.innerHTML;$(n).html("").append(font)}});rng.moveToBookmark(bk).select()}return true}},queryCommandValue:function(cmdName){var start=me.selection.getStart();var val=$(start).css(cmdNameToStyle[cmdName]);if(val===undefined){val=$(start).attr(cmdNameToAttr[cmdName])}return val?utils.fixColor(cmdName,val).replace(/px/,""):""},queryCommandState:function(cmdName){return this.queryCommandValue(cmdName)}}})(p)}};UM.plugins["link"]=function(){var me=this;me.setOpt("autourldetectinie",false);if(browser.ie&&this.options.autourldetectinie===false){this.addListener("keyup",function(cmd,evt){var me=this,keyCode=evt.keyCode;if(keyCode==13||keyCode==32){var rng=me.selection.getRange();var start=rng.startContainer;if(keyCode==13){if(start.nodeName=="P"){var pre=start.previousSibling;if(pre&&pre.nodeType==1){var pre=pre.lastChild;if(pre&&pre.nodeName=="A"&&!pre.getAttribute("_href")){domUtils.remove(pre,true)}}}}else if(keyCode==32){if(start.nodeType==3&&/^\s$/.test(start.nodeValue)){start=start.previousSibling;if(start&&start.nodeName=="A"&&!start.getAttribute("_href")){domUtils.remove(start,true)}}}}})}this.addOutputRule(function(root){$.each(root.getNodesByTagName("a"),function(i,a){var _href=a.getAttr("href");if(!/^(ftp|https?|\/|file)/.test(_href)){_href="http://"+_href}if(_href!="http://undefined")a.setAttr("href",_href);a.setAttr("href",_href);a.setAttr("_href");if(a.getAttr("title")==""){a.setAttr("title")}})});this.addInputRule(function(root){$.each(root.getNodesByTagName("a"),function(i,a){a.setAttr("_href",a.getAttr("href"))})});me.commands["link"]={execCommand:function(cmdName,opt){var me=this;var rng=me.selection.getRange();opt._href&&(opt._href=utils.unhtml(opt._href,/[<">'](?:(amp|lt|quot|gt|#39|nbsp);)?/g));opt.href&&(opt.href=utils.unhtml(opt.href,/[<">'](?:(amp|lt|quot|gt|#39|nbsp);)?/g));if(rng.collapsed){var start=rng.startContainer;if(start=domUtils.findParentByTagName(start,"a",true)){$(start).attr(opt);rng.selectNode(start).select()}else{rng.insertNode($(""+opt.href+"").attr(opt)[0]).select()}}else{me.document.execCommand("createlink",false,"_umeditor_link");utils.each(domUtils.getElementsByTagName(me.body,"a",function(n){return n.getAttribute("href")=="_umeditor_link"}),function(l){if($(l).text()=="_umeditor_link"){$(l).text(opt.href)}domUtils.setAttributes(l,opt);rng.selectNode(l).select()})}},queryCommandState:function(){return this.queryCommandValue("link")?1:0},queryCommandValue:function(){var path=this.selection.getStartElementPath();var result;$.each(path,function(i,n){if(n.nodeName=="A"){result=n;return false}});return result}};me.commands["unlink"]={execCommand:function(){this.document.execCommand("unlink")}}};UM.commands["print"]={execCommand:function(){var me=this,id="editor_print_"+ +new Date;$('').attr("id",id).css({width:"0px",height:"0px",overflow:"hidden",float:"left",position:"absolute",top:"-10000px",left:"-10000px"}).appendTo(me.$container.find(".edui-dialog-container"));var w=window.open("",id,""),d=w.document;d.open();d.write("
"+this.getContent(null,null,true)+"