//>>built
define("dojox/editor/plugins/BidiSupport","dojo/_base/declare dojo/_base/array dojo/aspect dojo/_base/lang dojo/dom-attr dojo/dom-class dojo/dom-construct dojo/i18n dojo/NodeList-dom dojo/NodeList-traverse dojo/dom-style dojo/sniff dojo/query dijit dojox dijit/_editor/_Plugin dijit/_editor/range dijit/_editor/plugins/EnterKeyHandling dijit/_editor/plugins/FontChoice ./NormalizeIndentOutdent dijit/form/ToggleButton dojo/i18n!./nls/BidiSupport".split(" "),function(H,x,B,t,n,I,p,J,N,O,h,m,v,P,Q,C,w,
F,K,L,M){var G=H("dojox.editor.plugins.BidiSupport",C,{useDefaultCommand:!1,buttonClass:null,iconClassPrefix:"dijitAdditionalEditorIcon",command:"bidiSupport",blockMode:"DIV",shortcutonly:!1,bogusHtmlContent:"\x26nbsp;",buttonLtr:null,buttonRtl:null,_indentBy:40,_lineTextArray:"DIV P LI H1 H2 H3 H4 H5 H6 ADDRESS PRE DT DE TD".split(" "),_lineStyledTextArray:"H1 H2 H3 H4 H5 H6 ADDRESS PRE P".split(" "),_tableContainers:["TABLE","THEAD","TBODY","TR"],_blockContainers:["TABLE","OL","UL","BLOCKQUOTE"],
_initButton:function(){this.shortcutonly||(this.buttonLtr||(this.buttonLtr=this._createButton("ltr")),this.buttonRtl||(this.buttonRtl=this._createButton("rtl")))},_createButton:function(c){return M(t.mixin({label:J.getLocalization("dojox.editor.plugins","BidiSupport")[c],dir:this.editor.dir,lang:this.editor.lang,showLabel:!1,iconClass:this.iconClassPrefix+" "+this.iconClassPrefix+("ltr"==c?"ParaLeftToRight":"ParaRightToLeft"),onClick:t.hitch(this,"_changeState",[c])},this.params||{}))},setToolbar:function(c){this.shortcutonly||
(this.editor.isLeftToRight()?(c.addChild(this.buttonLtr),c.addChild(this.buttonRtl)):(c.addChild(this.buttonRtl),c.addChild(this.buttonLtr)))},updateState:function(){if(this.editor&&this.editor.isLoaded&&!this.shortcutonly&&(this.buttonLtr.set("disabled",!!this.disabled),this.buttonRtl.set("disabled",!!this.disabled),!this.disabled)){var c=w.getSelection(this.editor.window);if(c&&0!=c.rangeCount){var a=c.getRangeAt(0);if(a.startContainer!==this.editor.editNode||a.startContainer.hasChildNodes()){c=
a.startContainer;a=a.startOffset;if(this._isBlockElement(c))for(;c.hasChildNodes();)a==c.childNodes.length&&a--,c=c.childNodes[a],a=0;c=this._getBlockAncestor(c)}else c=a.startContainer;c=h.get(c,"direction");this.buttonLtr.set("checked","ltr"==c);this.buttonRtl.set("checked","rtl"==c)}}},setEditor:function(c){this.editor=c;"P"!=this.blockMode&&"DIV"!=this.blockMode&&(this.blockMode="DIV");this._initButton();this.editor.contentPreFilters.push(this._preFilterNewLines);c=t.hitch(this,function(a){if(this.disabled||
!a.hasChildNodes())return a;this._changeStateOfBlocks(this.editor.editNode,this.editor.editNode,this.editor.editNode,"explicitdir",null);return this.editor.editNode});this.editor.contentDomPostFilters.push(c);this.editor._justifyleftImpl=t.hitch(this,function(){this._changeState("left");return!0});this.editor._justifyrightImpl=t.hitch(this,function(){this._changeState("right");return!0});this.editor._justifycenterImpl=t.hitch(this,function(){this._changeState("center");return!0});this.editor._insertorderedlistImpl=
t.hitch(this,"_insertLists","insertorderedlist");this.editor._insertunorderedlistImpl=t.hitch(this,"_insertLists","insertunorderedlist");this.editor._indentImpl=t.hitch(this,"_indentAndOutdent","indent");this.editor._outdentImpl=t.hitch(this,"_indentAndOutdent","outdent");this.editor._formatblockImpl=t.hitch(this,"_formatBlocks");this.editor.onLoadDeferred.addCallback(t.hitch(this,function(){var a=this.editor._plugins,b=a.length;var d=t.hitch(this,"_changeState","mirror");var e=t.hitch(this,"_changeState",
"ltr");var f=t.hitch(this,"_changeState","rtl");this.editor.addKeyHandler("9",1,0,d);this.editor.addKeyHandler("8",1,0,e);this.editor.addKeyHandler("0",1,0,f);for(d=0;d<a.length;d++)if(e=a[d])e.constructor===F?(e.destroy(),e=null,b=d):e.constructor===L?(this.editor._normalizeIndentOutdent=!0,this.editor._indentImpl=t.hitch(this,"_indentAndOutdent","indent"),this.editor._outdentImpl=t.hitch(this,"_indentAndOutdent","outdent")):e.constructor===K&&"formatBlock"===e.command&&this.own(B.before(e.button,
"_execCommand",t.hitch(this,"_handleNoFormat")));this.editor.addPlugin({ctor:F,blockNodeForEnter:this.blockMode,blockNodes:/^(?:P|H1|H2|H3|H4|H5|H6|LI|DIV)$/},b);e=this.editor._plugins[b];this.own(B.after(e,"handleEnterKey",t.hitch(this,"_checkNewLine"),!0))}));this.own(B.after(this.editor,"onNormalizedDisplayChanged",t.hitch(this,"updateState"),!0))},_checkNewLine:function(){var c=w.getSelection(this.editor.window).getRangeAt(0);c=w.getBlockAncestor(c.startContainer,null,this.editor.editNode).blockNode;
c.innerHTML===this.bogusHtmlContent&&c.previousSibling?c.style.cssText=c.previousSibling.style.cssText:c.innerHTML!==this.bogusHtmlContent&&c.previousSibling&&c.previousSibling.innerHTML===this.bogusHtmlContent&&(c.previousSibling.style.cssText=c.style.cssText)},_handleNoFormat:function(c,a,b){return"noFormat"===b?[c,a,"DIV"]:arguments},_execNativeCmd:function(c,a,b){if(this._isSimpleInfo(b))return c=this.editor.document.execCommand(c,!1,a),m("webkit")&&v("table",this.editor.editNode).prev().forEach(function(y,
z,A){this._hasTag(y,"BR")&&y.parentNode.removeChild(y)},this),c;var d=w.getSelection(this.editor.window);if(!d||0==d.rangeCount)return!1;var e=d.getRangeAt(0),f=e.cloneRange(),g=e.startContainer,l=e.startOffset,k=e.endContainer;e=e.endOffset;for(var q=0;q<b.groups.length;q++){var r=b.groups[q],u=r[r.length-1].childNodes.length;f.setStart(r[0],0);f.setEnd(r[r.length-1],u);d.removeAllRanges();d.addRange(f);u=this.editor.selection.getParentOfType(r[0],["TABLE"]);r=this.editor.document.execCommand(c,
!1,a);m("webkit")&&(u&&this._hasTag(u.previousSibling,"BR")&&u.parentNode.removeChild(u.previousSibling),this.editor.focus(),d=w.getSelection(this.editor.window),u=d.getRangeAt(0),0==q?(g=u.endContainer,l=u.endOffset):q==b.groups.length-1&&(k=u.endContainer,e=u.endOffset));if(!r)break;m("webkit")&&this._changeState(c)}d.removeAllRanges();try{f.setStart(g,l),f.setEnd(k,e),d.addRange(f)}catch(y){}return!0},_insertLists:function(c){var a=this._changeState("preparelists",c);if(!this._execNativeCmd(c,
null,a))return!1;m("webkit")&&!this._isSimpleInfo(a)||this._changeState(c);this._cleanLists();this._mergeLists();return!0},_indentAndOutdent:function(c){if(this.editor._normalizeIndentOutdent)return this._changeState("normalize"+c),!0;var a=this._changeState("prepare"+c);if(m("mozilla")){try{var b=this.editor.document.queryCommandValue("styleWithCSS")}catch(d){b=!1}this.editor.document.execCommand("styleWithCSS",!1,!0)}a=this._execNativeCmd(c,null,a);m("mozilla")&&this.editor.document.execCommand("styleWithCSS",
!1,b);if(!a)return!1;this._changeState(c);this._mergeLists();return!0},_formatBlocks:function(c){if(m("mozilla")||m("webkit"))var a=this._changeState("prepareformat",c);m("ie")&&c&&"\x3c"!=c.charAt(0)&&(c="\x3c"+c+"\x3e");if(!this._execNativeCmd("formatblock",c,a))return!1;m("webkit")&&!this._isSimpleInfo(a)||this._changeState("formatblock",c);this._mergeLists();return!0},_changeState:function(c,a){if(this.editor.window){this.editor.focus();var b=w.getSelection(this.editor.window);if(b&&0!=b.rangeCount){var d=
b.getRangeAt(0),e=d.cloneRange();var f=d.startContainer;b=d.startOffset;var g=d.endContainer;var l=d.endOffset;d=f===g&&b==l;if(this._isBlockElement(f)||this._hasTagFrom(f,this._tableContainers))for(;f.hasChildNodes();)b==f.childNodes.length&&b--,f=f.childNodes[b],b=0;e.setStart(f,b);f=this._getClosestBlock(f,"start",e);(b=w.getBlockAncestor(f,/li/i,this.editor.editNode).blockNode)&&b!==f&&(f=b);g=e.endContainer;l=e.endOffset;if(this._isBlockElement(g)||this._hasTagFrom(g,this._tableContainers))for(;g.hasChildNodes();)l==
g.childNodes.length&&l--,g=g.childNodes[l],l=g.hasChildNodes()?g.childNodes.length:3==g.nodeType&&g.nodeValue?g.nodeValue.length:0;e.setEnd(g,l);g=this._getClosestBlock(g,"end",e);(b=w.getBlockAncestor(g,/li/i,this.editor.editNode).blockNode)&&b!==g&&(g=b);b=w.getSelection(this.editor.window,!0);b.removeAllRanges();b.addRange(e);b=w.getCommonAncestor(f,g);f=this._changeStateOfBlocks(f,g,b,c,a,e);d&&(g=e.startContainer,l=e.startOffset,e.setEnd(g,l),b=w.getSelection(this.editor.window,!0),b.removeAllRanges(),
b.addRange(e));return f}}},_isBlockElement:function(c){if(!c||1!=c.nodeType)return!1;c=h.get(c,"display");return"block"==c||"list-item"==c||"table-cell"==c},_isInlineOrTextElement:function(c){return!this._isBlockElement(c)&&(1==c.nodeType||3==c.nodeType||8==c.nodeType)},_isElement:function(c){return c&&(1==c.nodeType||3==c.nodeType)},_isBlockWithText:function(c){return c!==this.editor.editNode&&this._hasTagFrom(c,this._lineTextArray)},_getBlockAncestor:function(c){for(;c.parentNode&&!this._isBlockElement(c);)c=
c.parentNode;return c},_getClosestBlock:function(c,a,b){if(this._isBlockElement(c))return c;var d=c.parentNode,e,f=!1;for(removeOffset=!1;;){var g=c;for(f=!1;;){if(this._isInlineOrTextElement(g)){var l=g;e||(e=g)}g=g.previousSibling;if(!g)break;else if(this._isBlockElement(g)||this._hasTagFrom(g,this._blockContainers)||this._hasTag(g,"BR")){f=!0;break}else if(3==g.nodeType&&3==g.nextSibling.nodeType&&(g.nextSibling.nodeValue=g.nodeValue+g.nextSibling.nodeValue,"start"==a&&g===b.startContainer?b.setStart(g.nextSibling,
0):"end"!=a||g!==b.endContainer&&g.nextSibling!==b.endContainer||b.setEnd(g.nextSibling,g.nextSibling.nodeValue.length),g=g.nextSibling,g.parentNode.removeChild(g.previousSibling),!g.previousSibling))break}for(g=c;this._isInlineOrTextElement(g)&&(l||(l=g),e=g),g=g.nextSibling,g;)if(this._isBlockElement(g)||this._hasTagFrom(g,this._blockContainers)){f=!0;break}else if(this._hasTag(g,"BR")&&g.nextSibling&&!this._isBlockElement(g.nextSibling)&&!this._hasTagFrom(g.nextSibling,this._blockContainers)){e=
g;f=!0;break}else if(3==g.nodeType&&3==g.previousSibling.nodeType&&(g.previousSibling.nodeValue+=g.nodeValue,"start"==a&&g===b.startContainer?b.setStart(g.previousSibling,0):"end"!=a||g!==b.endContainer&&g.previousSibling!==b.endContainer||b.setEnd(g.previousSibling,g.previousSibling.nodeValue.length),g=g.previousSibling,g.parentNode.removeChild(g.nextSibling),!g.nextSibling))break;if(f||this._isBlockElement(d)&&!this._isBlockWithText(d)&&l){c=b?b.startOffset:0;f=b?b.endOffset:0;g=b?b.startContainer:
null;var k=b?b.endContainer:null;d=this._repackInlineElements(l,e,d);a=d["start"==a?0:d.length-1];b&&a&&l===g&&this._hasTag(l,"BR")&&(g=a,c=0,e===l&&(k=g,f=0));b&&(b.setStart(g,c),b.setEnd(k,f));return a}if(this._isBlockElement(d))return d;c=d;removeOffset=!0;d=d.parentNode;l=e=null}},_changeStateOfBlocks:function(c,a,b,d,e,f){var g=[];if(c===this.editor.editNode){if(!c.hasChildNodes())return;this._isInlineOrTextElement(c.firstChild)&&this._rebuildBlock(c);c=this._getClosestBlock(c.firstChild,"start",
null)}if(a===this.editor.editNode){if(!a.hasChildNodes())return;this._isInlineOrTextElement(a.lastChild)&&this._rebuildBlock(a);a=this._getClosestBlock(a.lastChild,"end",null)}var l=f?f.startOffset:0,k=f?f.endOffset:0,q=f?f.startContainer:null,r=f?f.endContainer:null;c=this._collectNodes(c,a,b,f,g,q,l,r,k,d);g={nodes:g,groups:c.groups,cells:c.cells};d=d.toString();switch(d){case "mirror":case "ltr":case "rtl":case "left":case "right":case "center":case "explicitdir":this._execDirAndAlignment(g,d,
e);break;case "preparelists":this._prepareLists(g,e);break;case "insertorderedlist":case "insertunorderedlist":this._execInsertLists(g);break;case "prepareoutdent":this._prepareOutdent(g);break;case "prepareindent":this._prepareIndent(g);break;case "indent":this._execIndent(g);break;case "outdent":this._execOutdent(g);break;case "normalizeindent":this._execNormalizedIndent(g);break;case "normalizeoutdent":this._execNormalizedOutdent(g);break;case "prepareformat":this._prepareFormat(g,e);break;case "formatblock":this._execFormatBlocks(g,
e)}f&&(f.setStart(q,l),f.setEnd(r,k),sel=w.getSelection(this.editor.window,!0),sel.removeAllRanges(),sel.addRange(f),this.editor.onDisplayChanged());return g},_collectNodes:function(c,a,b,d,e,f,g,l,k,q){d=c.parentNode;l=[];var r=[],u=[],y=[],z=this.editor.editNode;f=t.hitch(this,function(D){e.push(D);var E=this.editor.selection.getParentOfType(D,["TD"]);if(z!==E||m("webkit")&&("prepareformat"===q||"preparelists"===q))u.length&&r.push(u),u=[],z!=E&&(z=E)&&y.push(z);u.push(D)});for(this._rebuildBlock(d);;){if(this._hasTagFrom(c,
this._tableContainers)){if(c.firstChild){d=c;c=c.firstChild;continue}}else if(this._isBlockElement(c)){if((g=w.getBlockAncestor(c,/li/i,this.editor.editNode).blockNode)&&g!==c){c=g;d=c.parentNode;continue}if(!this._hasTag(c,"LI")&&c.firstChild&&(this._rebuildBlock(c),this._isBlockElement(c.firstChild)||this._hasTagFrom(c.firstChild,this._tableContainers))){d=c;c=c.firstChild;continue}this._hasTagFrom(c,this._lineTextArray)&&f(c)}else if(this._isInlineOrTextElement(c)&&!this._hasTagFrom(c.parentNode,
this._tableContainers)){for(l=c;c;){g=c.nextSibling;if(this._isInlineOrTextElement(c)){var A=c;if(this._hasTag(c,"BR")&&(!this._isBlockElement(d)||c!==d.lastChild)){l=this._repackInlineElements(l,A,d);c=l[l.length-1];for(k=0;k<l.length;k++)f(l[k]);l=A=null;g&&this._isInlineOrTextElement(g)&&(l=g)}}else if(this._isBlockElement(c))break;c=g}if(!l)continue;l=this._repackInlineElements(l,A,d);c=l[l.length-1];for(k=0;k<l.length;k++)f(l[k])}if(c===a)break;if(c.nextSibling)c=c.nextSibling;else if(d!==b){for(;!d.nextSibling&&
(c=d,d=c.parentNode,d!==b););if(d!==b&&d.nextSibling)c=d.nextSibling,d=d.parentNode;else break}else break}u.length&&(m("webkit")||z?r.push(u):r.unshift(u));return{groups:r,cells:y}},_execDirAndAlignment:function(c,a,b){switch(a){case "mirror":case "ltr":case "rtl":x.forEach(c.nodes,function(d){var e=h.getComputedStyle(d),f=e.direction,g="mirror"!=a?a:"ltr"==f?"rtl":"ltr",l=e.textAlign,k=isNaN(parseInt(e.marginLeft))?0:parseInt(e.marginLeft);e=isNaN(parseInt(e.marginRight))?0:parseInt(e.marginRight);
n.remove(d,"dir");n.remove(d,"align");h.set(d,{direction:g,textAlign:""});if(!this._hasTag(d,"CENTER"))if(0<=l.indexOf("center")&&h.set(d,"textAlign","center"),this._hasTag(d,"LI")){this._refineLIMargins(d);k="rtl"===f?e:k;e=0;var q=d.parentNode;if(f!=h.get(q,"direction")){for(;q!==this.editor.editNode;)this._hasTagFrom(q,["OL","UL"])&&e++,q=q.parentNode;k-=this._getMargins(e)}f="rtl"==g?"marginRight":"marginLeft";e=h.get(d,f);e=isNaN(e)?0:parseInt(e);h.set(d,f,""+(e+k)+"px");m("webkit")?0>l.indexOf("center")&&
h.set(d,"textAlign","rtl"==g?"right":"left"):d.firstChild&&d.firstChild.tagName&&this._hasTagFrom(d.firstChild,this._lineStyledTextArray)&&(e=h.getComputedStyle(d),l=this._refineAlignment(e.direction,e.textAlign),m("mozilla")?h.set(d.firstChild,{textAlign:l}):h.set(d.firstChild,{direction:g,textAlign:l}))}else"rtl"==g&&0!=k?h.set(d,{marginLeft:"",marginRight:""+k+"px"}):"ltr"==g&&0!=e&&h.set(d,{marginRight:"",marginLeft:""+e+"px"})},this);v("table",this.editor.editNode).forEach(function(d,e,f){e=
a;"mirror"===a&&(e="ltr"===h.get(d,"direction")?"rtl":"ltr");f=v("td",d);for(var g=!1,l=!1,k=0;k<c.cells.length;k++)if(!g&&f[0]===c.cells[k])g=!0;else if(f[f.length-1]===c.cells[k]){l=!0;break}if(g&&l)for(h.set(d,"direction",e),k=0;k<f.length;k++)h.set(f[k],"direction",e)},this);break;case "left":case "right":case "center":x.forEach(c.nodes,function(d){if(!this._hasTag(d,"CENTER")&&(n.remove(d,"align"),h.set(d,"textAlign",a),this._hasTag(d,"LI")&&d.firstChild&&d.firstChild.tagName&&this._hasTagFrom(d.firstChild,
this._lineStyledTextArray))){var e=h.getComputedStyle(d);e=this._refineAlignment(e.direction,e.textAlign);h.set(d.firstChild,"textAlign",e)}},this);break;case "explicitdir":x.forEach(c.nodes,function(d){var e=h.getComputedStyle(d).direction;n.remove(d,"dir");h.set(d,{direction:e})},this)}},_prepareLists:function(c,a){x.forEach(c.nodes,function(b,d,e){if(m("mozilla")||m("webkit")){m("mozilla")&&(d=this._getParentFrom(b,["TD"]))&&0==v("div[tempRole]",d).length&&p.create("div",{innerHTML:"\x3cspan tempRole\x3d'true'\x3e"+
this.bogusHtmlContent+"\x3c/span",tempRole:"true"},d);d=this._tag(b);if(m("webkit")&&this._hasTagFrom(b,this._lineStyledTextArray)||this._hasTag(b,"LI")&&this._hasStyledTextLineTag(b.firstChild)){var f=this._hasTag(b,"LI")?this._tag(b.firstChild):d;if(this._hasTag(b,"LI")){for(;b.firstChild.lastChild;)p.place(b.firstChild.lastChild,b.firstChild,"after");b.removeChild(b.firstChild)}f=p.create("span",{innerHTML:this.bogusHtmlContent,bogusFormat:f},b,"first")}if(m("webkit")||"DIV"==d||"P"==d||"LI"==
d)if(m("webkit")&&this._isListTypeChanged(b,a)&&b===b.parentNode.lastChild&&p.create("li",{tempRole:"true"},b,"after"),!("LI"==d&&b.firstChild&&b.firstChild.tagName&&this._hasTagFrom(b.firstChild,this._lineStyledTextArray))){var g=h.getComputedStyle(b);e=g.direction;g=g.textAlign;g=this._refineAlignment(e,g);var l=this._getLIIndent(b);l=0==l?"":""+l+"px";m("webkit")&&"LI"==d&&h.set(b,"textAlign","");b=f?b.firstChild:p.create("span",{innerHTML:this.bogusHtmlContent},b,"first");n.set(b,"bogusDir",e);
""!=g&&n.set(b,"bogusAlign",g);l&&n.set(b,"bogusMargin",l)}}else if(m("ie")&&this._hasTag(b,"LI")&&(h.getComputedStyle(b),h.set(b,"marginRight",""),h.set(b,"marginLeft",""),1==this._getLILevel(b)&&!this._isListTypeChanged(b,cmd)&&(b.firstChild&&this._hasTagFrom(b.firstChild,["P","PRE"])&&p.create("span",{bogusIEFormat:this._tag(b.firstChild)},b.firstChild,"first"),this._hasTag(b.firstChild,"PRE")))){for(f=p.create("p",null,b.firstChild,"after");b.firstChild.firstChild;)p.place(b.firstChild.firstChild,
f,"last");f.style.cssText=b.style.cssText;b.removeChild(b.firstChild)}},this);m("webkit")&&v("table",this.editor.editNode).forEach(function(b,d,e){(d=b.nextSibling)&&this._hasTagFrom(d,["UL","OL"])&&p.create("UL",{tempRole:"true"},b,"after")},this)},_execInsertLists:function(c){x.forEach(c.nodes,function(a,b){if(this._hasTag(a,"LI")){if(a.firstChild&&a.firstChild.tagName&&this._hasTagFrom(a.firstChild,this._lineStyledTextArray)){var d=h.getComputedStyle(a.firstChild),e=this._refineAlignment(d.direction,
d.textAlign);h.set(a,{direction:d.direction,textAlign:e});var f=this._getIntStyleValue(a,"marginLeft")+this._getIntStyleValue(a.firstChild,"marginLeft"),g=this._getIntStyleValue(a,"marginRight")+this._getIntStyleValue(a.firstChild,"marginRight");h.set(a,{marginLeft:f?""+f+"px":"",marginRight:g?""+g+"px":""});h.set(a.firstChild,{direction:"",textAlign:""});m("mozilla")||h.set(a.firstChild,{marginLeft:"",marginRight:""})}for(;1<a.childNodes.length&&3==a.lastChild.nodeType&&a.lastChild.previousSibling&&
3==a.lastChild.previousSibling.nodeType&&""==t.trim(a.lastChild.nodeValue);)a.removeChild(a.lastChild);if(m("safari")&&this._hasTag(a.firstChild,"SPAN")&&I.contains(a.firstChild,"Apple-style-span")&&(f=a.firstChild,this._hasTag(f.firstChild,"SPAN")&&n.has(f.firstChild,"bogusFormat"))){for(;f.lastChild;)p.place(f.lastChild,f,"after");a.removeChild(f)}}else if(this._hasTag(a,"DIV")&&0==a.childNodes.length){a.parentNode.removeChild(a);return}if(m("ie")){if(this._hasTag(a,"P")&&"DIV"==this.blockMode.toUpperCase()){if(this._hasTag(a.firstChild,
"SPAN")&&n.has(a.firstChild,"bogusIEFormat")){"PRE"===n.get(a.firstChild,"bogusIEFormat").toUpperCase()?(f=p.create("pre",{innerHTML:a.innerHTML},a,"before"),f.style.cssText=a.style.cssText,f.removeChild(f.firstChild),a.parentNode.removeChild(a)):a.removeChild(a.firstChild);return}f=p.create("div");f.style.cssText=a.style.cssText;for(a.parentNode.insertBefore(f,a);a.firstChild;)f.appendChild(a.firstChild);a.parentNode.removeChild(a)}if(!this._hasTag(a,"LI"))return;this._refineLIMargins(a);f=a.firstChild;
if(!this._hasTag(f,"DIV")||f!==a.lastChild)return;d=h.getComputedStyle(f);var l=d.direction;e=d.textAlign;h.getComputedStyle(a);h.set(a,"direction",l);e=this._refineAlignment(l,e);for(h.set(a,"textAlign",e);f.firstChild;)a.insertBefore(f.firstChild,f);a.removeChild(f)}else if(!this._hasTag(a.firstChild,"SPAN")){this._hasTag(a,"LI")&&(this._refineLIMargins(a),m("mozilla")&&this._hasStyledTextLineTag(a.firstChild)&&this._recountLIMargins(a));return}var k=!1,q=f=!1;g=0;n.has(a.firstChild,"bogusDir")&&
(k=!0,l=n.get(a.firstChild,"bogusDir"),h.set(a,"direction",l));if(n.has(a.firstChild,"bogusAlign")&&(q=k=!0,e=n.get(a.firstChild,"bogusAlign"),h.set(a,"textAlign",e),d=a.firstChild.nextSibling,this._hasTag(d,"SPAN")&&h.get(d,"textAlign")===e&&(h.set(d,"textAlign",""),""==d.style.cssText))){for(;d.lastChild;)p.place(d.lastChild,d,"after");a.removeChild(d)}n.has(a.firstChild,"bogusMargin")&&(f=k=!0,g=parseInt(n.get(a.firstChild,"bogusMargin")),this._hasTag(a,"LI")||(d="rtl"===h.get(a,"direction")?"marginRight":
"marginLeft",e=this._getIntStyleValue(a,d)+g,h.set(a,d,0==e?"":""+e+"px")));if(n.has(a.firstChild,"bogusFormat")){k=!1;n.remove(a.firstChild,"bogusDir");if(a.firstChild.nextSibling&&this._hasTag(a.firstChild.nextSibling,"SPAN")){e=a.firstChild.style.cssText.trim().split(";");l=a.firstChild.nextSibling.style.cssText.trim().split(";");for(var r=0;r<e.length;r++)if(e[r])for(d=0;d<l.length;d++)if(e[r].trim()==l[d].trim()){d=e[r].trim().split(":")[0];h.set(a.firstChild.nextSibling,d,"");break}if(""===
a.firstChild.nextSibling.style.cssText){for(;a.firstChild.nextSibling.firstChild;)p.place(a.firstChild.nextSibling.firstChild,a.firstChild.nextSibling,"after");a.removeChild(a.firstChild.nextSibling)}}d=n.get(a.firstChild,"bogusFormat");for(e=p.create(d,null,a.firstChild,"after");e.nextSibling;)p.place(e.nextSibling,e,"last");a.removeChild(a.firstChild);m("webkit")&&this._hasTag(a,"LI")&&(l=a.parentNode.parentNode,this._hasTag(l,d)&&n.set(l,"tempRole","true"));1!=a.childNodes.length||this._hasTag(a,
"TD")||(m("mozilla")||this._hasTag(a,"LI")?this._hasTag(a,"LI")||(e.style.cssText=a.style.cssText,p.place(e,a,"after"),n.set(a,"tempRole","true")):(e.style.cssText=a.style.cssText,n.set(a,"tempRole","true")))}k&&a.removeChild(a.firstChild);this._hasTag(a,"LI")&&(m("webkit")&&!q&&"center"!=h.get(a,"textAlign")&&h.set(a,"textAlign","rtl"==h.get(a,"direction")?"right":"left"),m("safari")&&this._hasTag(a,"DIV")&&(a.innerHTML=a.nextSibling.innerHTML,a.parentNode.removeChild(a.nextSibling)),k=a.parentNode.parentNode,
k!==this.editor.editNode&&this._hasTag(k,"DIV")&&1==k.childNodes.length&&(k.parentNode.insertBefore(a.parentNode,k),k.parentNode.removeChild(k)),this._refineLIMargins(a),f&&this._recountLIMargins(a,g))},this);m("mozilla")?v("*[tempRole]",this.editor.editNode).forEach(function(a,b,d){if(this._hasTag(a,"SPAN")){if(n.get(a.parentNode,"tempRole"))return;if(this._hasTag(a.parentNode,"LI")){a.parentNode.parentNode.removeChild(a.parentNode);return}}a.parentNode.removeChild(a)},this):m("webkit")&&v("*[tempRole]",
this.editor.editNode).forEach(function(a,b,d){if(!this._hasTag(a,"LI")&&!this._hasTag(a,"UL")){for(;a.lastChild;)p.place(a.lastChild,a,"after");a.parentNode.removeChild(a)}},this)},_execNormalizedIndent:function(c){x.forEach(c.nodes,function(a){var b="rtl"===h.get(a,"direction")?"marginRight":"marginLeft",d=h.get(a,b);d=isNaN(d)?0:parseInt(d);h.set(a,b,""+(d+this._indentBy)+"px")},this)},_execNormalizedOutdent:function(c){x.forEach(c.nodes,function(a){var b="rtl"===h.get(a,"direction")?"marginRight":
"marginLeft",d=h.get(a,b);d=isNaN(d)?0:parseInt(d);var e=0;if("LI"===a.tagName.toUpperCase()){var f=0,g=a.parentNode;if(h.get(a,"direction")!=h.get(g,"direction")){for(;g!==this.editor.editNode;)this._hasTagFrom(g,["OL","UL"])&&f++,g=g.parentNode;e=this._getMargins(f)}}d>=this._indentBy+e&&h.set(a,b,d==this._indentBy?"":""+(d-this._indentBy)+"px")},this)},_prepareIndent:function(c){x.forEach(c.nodes,function(a){if(m("mozilla")){var b=this._getParentFrom(a,["TD"]);b&&0==v("div[tempRole]",b).length&&
p.create("div",{innerHTML:this.bogusHtmlContent,tempRole:"true"},b);this._hasTag(a,"LI")&&(b=this._getLIIndent(a),n.set(a,"tempIndent",b))}if(m("webkit")&&this._hasTag(a,"LI")&&this._hasStyledTextLineTag(a.firstChild)){for(b=this._tag(a.firstChild);a.firstChild.lastChild;)p.place(a.firstChild.lastChild,a.firstChild,"after");a.removeChild(a.firstChild);p.create("span",{innerHTML:this.bogusHtmlContent,bogusFormat:b},a,"first")}},this)},_prepareOutdent:function(c){x.forEach(c.nodes,function(a){if(m("mozilla")||
m("webkit")){if(m("mozilla")){var b=this._getParentFrom(a,["TD"]);b&&0==v("div[tempRole]",b).length&&p.create("div",{innerHTML:this.bogusHtmlContent,tempRole:"true"},b)}b=this._tag(a);if(m("mozilla")&&"LI"!==b)return;var d=null;if(m("webkit")&&this._hasTag(a,"LI")&&this._hasStyledTextLineTag(a.firstChild)){b=this._tag(a.firstChild);for(var e=a.firstChild;e.lastChild;)p.place(e.lastChild,e,"after");a.removeChild(a.firstChild);d=p.create("span",{innerHTML:this.bogusHtmlContent,bogusFormat:b},a,"first")}if(a.firstChild&&
a.firstChild.tagName&&this._hasTagFrom(a.firstChild,this._lineStyledTextArray)){m("mozilla")&&(a.firstChild.style.cssText=a.style.cssText,b="rtl"===h.get(a,"direction")?"marginRight":"marginLeft",e=this._getLIIndent(a),0<e&&h.set(a.firstChild,b,""+e+"px"));return}var f=h.getComputedStyle(a);e=f.direction;f=f.textAlign;f=this._refineAlignment(e,f);m("webkit")&&"LI"==b&&h.set(a,"textAlign","");b=d?a.firstChild:p.create("span",{innerHTML:this.bogusHtmlContent},a,"first");n.set(b,"bogusDir",e);""!=f&&
n.set(b,"bogusAlign",f);m("mozilla")&&(e=this._getLIIndent(a),n.set(b,"bogusIndent",e))}if(m("ie")&&"LI"==a.tagName.toUpperCase()&&(h.set(a,"marginLeft",""),h.set(a,"marginRight",""),1==this._getLILevel(a)&&(a.firstChild&&this._hasTagFrom(a.firstChild,["P","PRE"])&&p.create("span",{bogusIEFormat:this._tag(a.firstChild)},a.firstChild,"first"),this._hasTag(a.firstChild,"PRE")))){for(b=p.create("p",null,a.firstChild,"after");a.firstChild.firstChild;)p.place(a.firstChild.firstChild,b,"last");b.style.cssText=
a.style.cssText;a.removeChild(a.firstChild)}},this)},_execIndent:function(c){x.forEach(c.nodes,function(a){m("mozilla")||h.set(a,"margin","");if(this._hasTag(a,"LI")){var b=0;m("mozilla")&&n.has(a,"tempIndent")&&(b=parseInt(n.get(a,"tempIndent")),n.remove(a,"tempIndent"));this._refineLIMargins(a);m("mozilla")&&this._recountLIMargins(a,b)}if(n.has(a.firstChild,"bogusFormat")){b=n.get(a.firstChild,"bogusFormat");for(b=p.create(b,null,a.firstChild,"after");b.nextSibling;)p.place(b.nextSibling,b,"last");
a.removeChild(a.firstChild)}if(m("ie")||m("webkit"))for(a=a.parentNode;a!==this.editor.editNode;){a=w.getBlockAncestor(a,/blockquote/i,this.editor.editNode).blockNode;if(!a)break;n.has(a,"dir")&&n.remove(a,"dir");h.set(a,"marginLeft","");h.set(a,"marginRight","");h.set(a,"margin","");a=a.parentNode}},this);m("mozilla")&&(v("div[tempRole]",this.editor.editNode).forEach(function(a,b,d){a.parentNode.removeChild(a)}),v("ul,ol",this.editor.editNode).forEach(function(a,b,d){h.set(a,"marginLeft","");h.set(a,
"marginRight","")}))},_execOutdent:function(c){x.forEach(c.nodes,function(a){if(m("mozilla")||m("webkit")){if(!this._hasTag(a.firstChild,"SPAN")){this._hasTag(a,"LI")&&(this._refineLIMargins(a),m("mozilla")&&this._hasStyledTextLineTag(a.firstChild)&&(this._recountLIMargins(a),a.firstChild.style.cssText=""));return}var b=!1,d=!1,e=0;if(n.has(a.firstChild,"bogusDir")){b=!0;var f=n.get(a.firstChild,"bogusDir");h.set(a,"direction",f)}n.has(a.firstChild,"bogusAlign")&&(b=!0,f=n.get(a.firstChild,"bogusAlign"),
h.set(a,"textAlign",f));if(n.has(a.firstChild,"bogusIndent")&&(b=!0,e=parseInt(n.get(a.firstChild,"bogusIndent")),!this._hasTag(a,"LI"))){f="rtl"===h.get(a,"direction")?"marginRight":"marginLeft";var g=""+(this._getIntStyleValue(a,f)+e)+"px";h.set(a,f,g)}if(n.has(a.firstChild,"bogusFormat")){b=!0;f=n.get(a.firstChild,"bogusFormat");for(f=p.create(f,null,a.firstChild,"after");f.nextSibling;)p.place(f.nextSibling,f,"last");this._hasTag(a,"LI")||(f.style.cssText=a.style.cssText,d=!0)}if(b&&(a.removeChild(a.firstChild),
d)){for(;a.lastChild;)p.place(a.lastChild,a,"after");n.set(a,"tempRole","true")}m("webkit")&&this._hasTag(a,"LI")&&"center"!=h.get(a,"textAlign")&&h.set(a,"textAlign","rtl"==h.get(a,"direction")?"right":"left");m("mozilla")&&this._hasTag(a,"LI")&&(b=a.parentNode.parentNode,b!==this.editor.editNode&&this._hasTag(b,"DIV")&&1==b.childNodes.length&&(b.parentNode.insertBefore(a.parentNode,b),b.parentNode.removeChild(b)))}if(m("ie")&&this._hasTag(a,"P")&&"DIV"==this.blockMode.toUpperCase()){if(this._hasTag(a.firstChild,
"SPAN")&&n.has(a.firstChild,"bogusIEFormat")){"PRE"===n.get(a.firstChild,"bogusIEFormat").toUpperCase()?(e=p.create("pre",{innerHTML:a.innerHTML},a,"before"),e.style.cssText=a.style.cssText,e.removeChild(e.firstChild),a.parentNode.removeChild(a)):a.removeChild(a.firstChild);return}b=p.create("div");b.style.cssText=a.style.cssText;for(a.parentNode.insertBefore(b,a);a.firstChild;)b.appendChild(a.firstChild);a.parentNode.removeChild(a)}this._hasTag(a,"LI")&&(this._refineLIMargins(a),m("mozilla")&&this._recountLIMargins(a,
e))},this);(m("mozilla")||m("webkit"))&&v("div[tempRole]",this.editor.editNode).forEach(function(a,b,d){a.parentNode.removeChild(a)})},_prepareFormat:function(c,a){x.forEach(c.nodes,function(b){if(m("mozilla")&&this._hasTag(b,"LI")){if(b.firstChild&&!this._isBlockElement(b.firstChild)){var d=b.ownerDocument.createElement(a),e=b.firstChild;for(b.insertBefore(d,b.firstChild);e;)d.appendChild(e),e=e.nextSibling}d=this._getLIIndent(b);n.set(b,"tempIndent",d)}if(m("webkit")){if(this._hasTag(b,"LI")){if(this._hasStyledTextLineTag(b.firstChild)){for(;b.firstChild.lastChild;)p.place(b.firstChild.lastChild,
b.firstChild,"after");b.removeChild(b.firstChild)}var f=p.create("span",{innerHTML:this.bogusHtmlContent,bogusFormat:a},b,"first")}e=h.getComputedStyle(b);d=e.direction;e=e.textAlign;e=this._refineAlignment(d,e);b=f?b.firstChild:p.create("span",{innerHTML:this.bogusHtmlContent},b,"first");n.set(b,"bogusDir",d);""!=e&&n.set(b,"bogusAlign",e)}},this)},_execFormatBlocks:function(c,a){x.forEach(c.nodes,function(b){if(this._hasTagFrom(b,this._lineTextArray)){if(this._hasTag(b.parentNode,"DIV")&&b.parentNode!==
this.editor.editNode)for(;b.parentNode.lastChild&&(3==b.parentNode.lastChild.nodeType&&""==t.trim(b.parentNode.lastChild.nodeValue)||this._hasTag(b.parentNode.lastChild,"BR"));)b.parentNode.removeChild(b.parentNode.lastChild);if(this._hasTag(b.parentNode,"DIV")&&b.parentNode!==this.editor.editNode&&1==b.parentNode.childNodes.length){var d=b.parentNode,e=h.getComputedStyle(d),f=this._refineAlignment(e.direction,e.textAlign);h.set(b,{direction:e.direction,textAlign:f});f="rtl"===e.direction?"marginRight":
"marginLeft";e=parseInt(h.get(d,f));0==e||isNan(e)||h.set(b,f,e);d.parentNode.insertBefore(b,d);d.parentNode.removeChild(d)}}if(this._hasTag(b,"LI")){d=0;n.has(b,"tempIndent")&&(d=parseInt(n.get(b,"tempIndent")),n.remove(b,"tempIndent"));this._refineLIMargins(b);for(d&&this._recountLIMargins(b,d);1<b.childNodes.length&&3==b.lastChild.nodeType&&""==t.trim(b.lastChild.nodeValue);)b.removeChild(b.lastChild);if(this._hasTagFrom(b.firstChild,this._lineStyledTextArray))e=h.getComputedStyle(b),f=this._refineAlignment(e.direction,
e.textAlign),m("mozilla")||m("ie")&&this._hasTag(b,"LI")||h.set(b.firstChild,{direction:e.direction,textAlign:f});else if(this._hasTag(b.firstChild,"DIV")){for(d=b.firstChild;d.firstChild;)b.insertBefore(d.firstChild,d);b.removeChild(d)}if(m("ie")&&!this._hasTag(b.firstChild,"P")&&"\x3cp\x3e"===a){d=p.create("p");for(f=this._hasTagFrom(d.nextSibling,this._lineStyledTextArray)?d.nextSibling:b;f.firstChild;)p.place(f.firstChild,d,"last");p.place(d,b,"first");f!==b&&b.removeChild(f)}}if(m("webkit")){if(this._hasTag(b,
"DIV")){if(n.has(b,"tempRole"))return;if(this._hasTag(b.previousSibling,"LI")){for(;b.firstChild;)p.place(b.firstChild,b.previousSibling,"last");n.set(b,"tempRole",!0);b=b.previousSibling}}d=!1;n.has(b.firstChild,"bogusDir")&&(d=!0,f=n.get(b.firstChild,"bogusDir"),h.set(b,"direction",f));n.has(b.firstChild,"bogusAlign")&&(d=!0,f=n.get(b.firstChild,"bogusAlign"),h.set(b,"textAlign",f));if(n.has(b.firstChild,"bogusFormat")){d=!0;var g=n.get(b.firstChild,"bogusFormat");if("DIV"!==g.toUpperCase())for(f=
p.create(g,null,b.firstChild,"after");f.nextSibling;)p.place(f.nextSibling,f,"last");else f=b;if(m("safari")&&this._hasTag(b.nextSibling,"DIV")){for(;b.nextSibling.firstChild;)p.place(b.nextSibling.firstChild,f,"last");n.set(b.nextSibling,"tempRole","true")}}d&&b.removeChild(b.firstChild);g&&this._hasTag(b,"LI")&&(b=b.parentNode.parentNode,this._hasTag(b,g)&&n.set(b,"tempRole","true"))}},this);m("webkit")&&v("*[tempRole]",this.editor.editNode).forEach(function(b,d,e){for(;b.lastChild;)p.place(b.lastChild,
b,"after");b.parentNode.removeChild(b)},this)},_rebuildBlock:function(c){for(var a=c.firstChild,b,d,e=!1;a;){if(this._isInlineOrTextElement(a)&&!this._hasTagFrom(a,this._tableContainers))e=!this._hasTagFrom(c,this._lineTextArray),b||(b=a),d=a;else if(this._isBlockElement(a)||this._hasTagFrom(a,this._tableContainers))b&&(this._repackInlineElements(b,d,c),b=null),e=!0;a=a.nextSibling}e&&b&&this._repackInlineElements(b,d,c)},_repackInlineElements:function(c,a,b){var d=[],e=b.ownerDocument.createElement(this.blockMode),
f=c.previousSibling&&1==c.previousSibling.nodeType?c.previousSibling.style.cssText:b.style.cssText,g=b===this.editor.editNode;d.push(e);c=b.replaceChild(e,c);p.place(c,e,"after");for(g?h.set(e,"direction",h.get(this.editor.editNode,"direction")):e.style.cssText=f;c;){var l=c.nextSibling;if(this._isInlineOrTextElement(c)){if(this._hasTag(c,"BR")&&c!==a){var k=b.ownerDocument.createElement(this.blockMode);d.push(k);c=b.replaceChild(k,c);p.place(c,k,"after");g?h.set(k,"direction",h.get(this.editor.editNode,
"direction")):k.style.cssText=f}!this._hasTag(c,"BR")&&8!=c.nodeType||e.hasChildNodes()||(e.innerHTML=this.bogusHtmlContent);this._hasTag(c,"BR")&&m("ie")?c.parentNode.removeChild(c):8!=c.nodeType?e.appendChild(c):c.parentNode.removeChild(c);3==c.nodeType&&c.previousSibling&&3==c.previousSibling.nodeType&&(c.previousSibling.nodeValue+=c.nodeValue,c.parentNode.removeChild(c));k&&(e=k,k=null)}if(c===a)break;c=l}return d},_preFilterNewLines:function(c){c=c.split(/(<\/?pre.*>)/i);for(var a=!1,b=0;b<c.length;b++)0>
c[b].search(/<\/?pre/i)&&!a?c[b]=c[b].replace(/\n/g,"").replace(/\t+/g,"\u00a0").replace(/^\s+/,"\u00a0").replace(/\xA0\xA0+$/,""):0<=c[b].search(/<\/?pre/i)&&(a=!a);return c.join("")},_refineAlignment:function(c,a){return a=0<=a.indexOf("left")&&"rtl"==c?"left":0<=a.indexOf("right")&&"ltr"==c?"right":0<=a.indexOf("center")?"center":""},_refineLIMargins:function(c){var a=h.get(c,"direction"),b=h.get(c.parentNode,"direction"),d=0,e=c.parentNode;for(m("webkit")&&(b=h.get(this.editor.editNode,"direction"));e!==
this.editor.editNode;)this._hasTagFrom(e,["OL","UL"])&&d++,e=e.parentNode;h.set(c,"marginRight","");h.set(c,"marginLeft","");e="rtl"==a?"marginRight":"marginLeft";d=this._getMargins(d);a!=b&&h.set(c,e,""+d+"px")},_getMargins:function(c){if(0==c)return 0;var a=35;m("mozilla")?a=45:m("ie")&&(a=25);return a+40*(c-1)},_recountLIMargins:function(c,a){var b=h.get(c,"direction"),d=h.get(c.parentNode,"direction"),e="rtl"==b?"marginRight":"marginLeft",f=h.get(c,e),g=(isNaN(parseInt(f))?0:parseInt(f))+(a?a:
0);c.firstChild&&1==c.firstChild.nodeType&&(f=h.get(c.firstChild,e),g+=isNaN(parseInt(f))?0:parseInt(f),h.set(c.firstChild,{marginLeft:"",marginRight:""}));b!=d&&(g-=this._getMargins(this._getLILevel(c)));if(f=this._getListMargins(c))for(var l=0;l<f/40;l++){var k=p.create(this._tag(c.parentNode),null,c,"before");p.place(c,k,"last")}b!=d&&(g+=this._getMargins(this._getLILevel(c)));g&&h.set(c,e,""+g+"px")},_getLILevel:function(c){c=c.parentNode;for(var a=0;this._hasTagFrom(c,["UL","OL"]);)a++,c=c.parentNode;
return a},_getLIIndent:function(c){var a=c.parentNode,b=h.get(c,"direction"),d=h.get(a,"direction");a=this._getIntStyleValue(c,"rtl"===b?"marginRight":"marginLeft");c=b===d?0:this._getMargins(this._getLILevel(c));return a-c},_getListMargins:function(c){c=c.parentNode;for(var a,b=0;this._hasTagFrom(c,["UL","OL"]);)a="rtl"==h.get(c,"direction")?"marginRight":"marginLeft",a=h.get(c,a),b+=isNaN(parseInt(a))?0:parseInt(a),c=c.parentNode;return b},_tag:function(c){return c&&c.tagName&&c.tagName.toUpperCase()},
_hasTag:function(c,a){return c&&a&&c.tagName&&c.tagName.toUpperCase()===a.toUpperCase()},_hasStyledTextLineTag:function(c){return this._hasTagFrom(c,this._lineStyledTextArray)},_hasTagFrom:function(c,a){return c&&a&&c.tagName&&0<=x.indexOf(a,c.tagName.toUpperCase())},_getParentFrom:function(c,a){if(!c||!a||!a.length)return null;for(var b=c;b!==this.editor.editNode;){if(this._hasTagFrom(b,a))return b;b=b.parentNode}return null},_isSimpleInfo:function(c){return!c||2>c.groups.length},_isListTypeChanged:function(c,
a){if(!this._hasTag(c,"LI"))return!1;var b=c.parentNode;return this._hasTag(b,"UL")&&"insertorderedlist"===a||this._hasTag(b,"OL")&&"insertunorderedlist"===a},_getIntStyleValue:function(c,a){var b=parseInt(h.get(c,a));return isNaN(b)?0:b},_mergeLists:function(){var c=w.getSelection(this.editor.window),a=c&&0<c.rangeCount;if(a)var b=c.getRangeAt(0).cloneRange(),d=b.startContainer,e=b.startOffset,f=b.endContainer,g=b.endOffset;var l=!1;v("ul,ol",this.editor.editNode).forEach(function(k,q,r){if(n.has(k,
"tempRole"))k.parentNode.removeChild(k);else for(q=k.nextSibling;this._hasTag(q,this._tag(k));){for(;q.firstChild;)p.place(q.firstChild,k,"last"),l=!0;n.set(q,"tempRole","true");q=q.nextSibling}},this);if(a&&l){c.removeAllRanges();try{b.setStart(d,e),b.setEnd(f,g),c.addRange(b)}catch(k){}}},_cleanLists:function(){m("webkit")&&(v("table",this.editor.editNode).forEach(function(k,q,r){k=k.nextSibling;this._hasTag(k,"UL")&&"true"===n.get(k,"tempRole")&&k.parentNode.removeChild(k)},this),v("li[tempRole]",
this.editor.editNode).forEach(function(k,q,r){1==k.parentNode.childNodes.length?k.parentNode.parentNode.removeChild(k.parentNode):k.parentNode.removeChild(k)}));var c=w.getSelection(this.editor.window),a=c&&0<c.rangeCount;if(a)var b=c.getRangeAt(0).cloneRange(),d=b.startContainer,e=b.startOffset,f=b.endContainer,g=b.endOffset;var l=!1;v("span[bogusDir]",this.editor.editNode).forEach(function(k,q,r){r=q=k.firstChild;if(1==q.nodeType)for(;q;)r=q.nextSibling,p.place(q,k,"after"),l=!0,q=r;k.parentNode.removeChild(k)},
this);if(a&&l){c.removeAllRanges();try{b.setStart(d,e),b.setEnd(f,g),c.addRange(b)}catch(k){}}}});C.registry.bidiSupport=C.registry.bidisupport=function(c){return new G({})};return G});