editor-para-min.js revision 883d785f73cff98fbe2fe00953621713c1489729
YUI.add("editor-para",function(G){var C=function(){C.superclass.constructor.apply(this,arguments);},B="host",D="body",A="nodeChange",F=D+" > p",E="p";G.extend(C,G.Base,{_fixFirstPara:function(){var H=this.get(B),J=H.getInstance(),I;J.one("body").set("innerHTML","<"+E+">"+J.Selection.CURSOR+"</"+E+">");I=new J.Selection();I.focusCursor(true,false);},_onNodeChange:function(P){var V=this.get(B),O=V.getInstance();switch(P.changedType){case"enter":if(G.UA.webkit){if(P.changedEvent.shiftKey){V.execCommand("insertbr");P.changedEvent.preventDefault();}}if(G.UA.gecko&&V.get("defaultblock")!=="p"){var R=P.changedNode,Q,J,L=O.Selection.DEFAULT_BLOCK_TAG;if(!R.test(L)){R=R.ancestor(L);}Q=O.Node.create("<"+L+">"+O.Selection.CURSOR+"</"+L+">");J=new O.Selection();R.insert(Q,"after");J.focusCursor(true,false);P.changedEvent.preventDefault();}break;case"keydown":if(O.config.doc.childNodes.length<2){var W=O.config.doc.body.innerHTML;if(W&&W.length<5&&W.toLowerCase()=="<br>"){this._fixFirstPara();}}break;case"backspace-up":case"backspace-down":case"delete-up":if(!G.UA.ie){var H=O.all(F),U,T,N,K,I,M;T=O.one(D);if(H.item(0)){T=H.item(0);}U=T.one("br");if(U){U.removeAttribute("id");U.removeAttribute("class");}K=O.Selection.getText(T);K=K.replace(/ /g,"").replace(/\n/g,"");M=T.all("img");if(K.length===0&&!M.size()){if(!T.test(E)){this._fixFirstPara();}I=null;if(P.changedNode&&P.changedNode.test(E)){I=P.changedNode;}if(!I&&V._lastPara&&V._lastPara.inDoc()){I=V._lastPara;}if(I&&!I.test(E)){I=I.ancestor(E);}if(I){if(!I.previous()&&I.get("parentNode")&&I.get("parentNode").test(D)){P.changedEvent.frameEvent.halt();}}}if(G.UA.webkit){if(P.changedNode){T=P.changedNode;if(T.test("li")&&(!T.previous()&&!T.next())){N=T.get("innerHTML").replace("<br>","");if(N===""){if(T.get("parentNode")){T.get("parentNode").replace(O.Node.create("<br>"));P.changedEvent.frameEvent.halt();P.preventDefault();O.Selection.filterBlocks();}}}}}}if(G.UA.gecko){var Q=P.changedNode,S=O.config.doc.createTextNode(" ");Q.appendChild(S);Q.removeChild(S);}break;}},_afterEditorReady:function(){var I=this.get(B),J=I.getInstance(),H;if(J){J.Selection.filterBlocks();H=J.Selection.DEFAULT_BLOCK_TAG;F=D+" > "+H;E=H;}},_afterContentChange:function(){var H=this.get(B),I=H.getInstance();if(I&&I.Selection){I.Selection.filterBlocks();}},_afterPaste:function(){var H=this.get(B),J=H.getInstance(),I=new J.Selection();G.later(50,H,function(){J.Selection.filterBlocks();});},initializer:function(){var H=this.get(B);H.on(A,G.bind(this._onNodeChange,this));H.after("ready",G.bind(this._afterEditorReady,this));H.after("contentChange",G.bind(this._afterContentChange,this));if(G.Env.webkit){H.after("dom:paste",G.bind(this._afterPaste,this));}}},{NAME:"editorPara",NS:"editorPara",ATTRS:{host:{value:false}}});G.namespace("Plugin");G.Plugin.EditorPara=C;},"@VERSION@",{requires:["editor-base","selection"],skinnable:false});