YUI.add("editor-para",function(_,e){var t=function(){t.superclass.constructor.apply(this,arguments)},m="host",O="parentNode",C="p",A="<br>",x="firstChild";_.extend(t,_.Plugin.EditorParaBase,{_getRoot:function(){return this.get(m).getInstance().EditorSelection.ROOT},_onNodeChange:function(e){var t,o,a,n,r,c,i,d,s,l,g,h,p,f,N,u,E,v=this.get(m),S=v.getInstance(),b=S.EditorSelection.DEFAULT_BLOCK_TAG,k=":last-child",P=!1,T=this._getRoot();switch(e.changedType){case"enter-up":if(f=(p=this._lastPara||e.changedNode).one("br.yui-cursor"),this._lastPara&&delete this._lastPara,f&&(f.previous()||f.next())&&f.ancestor(C)&&f.remove(),p.test(b)||(f=p.ancestor(b))&&(p=f,0),p.test(b)&&(l=p.previous())){for(N=l.one(k);!P;)N&&(u=N.one(k))?N=u:P=!0;N&&v.copyStyles(N,p)}break;case"enter":if(_.UA.webkit&&e.changedEvent.shiftKey&&(v.execCommand("insertbr"),e.changedEvent.preventDefault()),e.changedNode.test("li")&&!_.UA.ie&&""===S.EditorSelection.getText(e.changedNode)&&(""!==(f=(g=e.changedNode.ancestor("ol,ul")).getAttribute("dir"))&&(f=' dir = "'+f+'"'),g=e.changedNode.ancestor(S.EditorSelection.BLOCKS),o=S.Node.create("<p"+f+">"+S.EditorSelection.CURSOR+"</p>"),g.insert(o,"after"),e.changedNode.remove(),e.changedEvent.halt(),(a=new S.EditorSelection).selectNode(o,!0,!1)),_.UA.gecko&&"p"!==v.get("defaultblock")&&!(g=e.changedNode).test("li")&&!g.ancestor("li")){if(g.test(b)||(g=g.ancestor(b)),o=S.Node.create("<"+b+"></"+b+">"),g.insert(o,"after"),(a=new S.EditorSelection).anchorOffset){for(l=a.anchorNode.get("textContent"),t=S.one(S.config.doc.createTextNode(l.substr(0,a.anchorOffset))),p=S.one(S.config.doc.createTextNode(l.substr(a.anchorOffset))),(r=a.anchorNode).setContent(""),(c=r.cloneNode()).append(p),i=!1,s=r;!i;)(s=s.get(O))&&!s.test(b)?((d=s.cloneNode()).set("innerHTML",""),d.append(c),n=s.get("childNodes"),E=!1,n.each(function(e){E&&d.append(e),e===r&&(E=!0)}),r=s,c=d):i=!0;p=c,a.anchorNode.append(t),p&&o.append(p)}(o=o.get(x)?o.get(x):o).prepend(S.EditorSelection.CURSOR),a.focusCursor(!0,!0),""!==S.EditorSelection.getText(o)&&S.EditorSelection.cleanCursor(),e.changedEvent.preventDefault()}break;case"keyup":_.UA.gecko&&T&&T.getHTML().length<20&&(T.one("> p")||this._fixFirstPara());break;case"backspace-up":case"backspace-down":case"delete-up":_.UA.ie||(f=T.all("> p"),g=T,(l=(g=f.item(0)?f.item(0):g).one("br"))&&(l.removeAttribute("id"),l.removeAttribute("class")),t=(t=S.EditorSelection.getText(g)).replace(/ /g,"").replace(/\n/g,""),p=g.all("img"),0!==t.length||p.size()||(g.test(C)||this._fixFirstPara(),h=null,(h=(h=!(h=e.changedNode&&e.changedNode.test(C)?e.changedNode:h)&&v._lastPara&&v._lastPara.inDoc()?v._lastPara:h)&&!h.test(C)?h.ancestor(C):h)&&!h.previous()&&h.get(O)&&h.get(O).compareTo(T)&&(e.changedEvent.frameEvent.halt(),e.preventDefault())),_.UA.webkit&&e.changedNode&&(e.preventDefault(),!(g=e.changedNode).test("li")||g.previous()||g.next()||""===g.get("innerHTML").replace(A,"")&&g.get(O)&&(g.get(O).replace(S.Node.create(A)),e.changedEvent.frameEvent.halt(),S.EditorSelection.filterBlocks()))),_.UA.gecko&&this._fixGeckoOnBackspace(S)}_.UA.gecko&&e.changedNode&&!e.changedNode.test(b)&&(h=e.changedNode.ancestor(b))&&(this._lastPara=h)},_fixGeckoOnBackspace:function(e){var t,o,e=new e.EditorSelection;e.isCollapsed&&"P"===e.anchorNode.get("nodeName")&&0!==e.anchorOffset&&(o=e.anchorNode.get("childNodes"),t=e.anchorNode.get("lastChild"),e.anchorOffset===o.size())&&"BR"===t.get("nodeName")&&(1===e.anchorOffset?e.selectNode(e.anchorNode,!0):(t=t.get("previousSibling")).get("nodeType")===Node.TEXT_NODE&&(offset=t.get("length"),e.getEditorOffset()===offset)&&e.selectNode(t,!0,offset))},initializer:function(){var e=this.get(m);e.editorBR?_.error("Can not plug EditorPara and EditorBR at the same time."):e.on("nodeChange",_.bind(this._onNodeChange,this))}},{NAME:"editorPara",NS:"editorPara",ATTRS:{host:{value:!1}}}),_.namespace("Plugin"),_.Plugin.EditorPara=t},"patched-v3.18.7",{requires:["editor-para-base"]});