editor-para-min.js revision 96c1e6aab172b57cf3566abee931c26676990044
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(q){var x=this.get(b),o=x.getInstance();switch(q.changedType){case"enter":if(g.UA.webkit){if(q.changedEvent.shiftKey){x.execCommand("insertbr");q.changedEvent.preventDefault();}}if(g.UA.gecko&&x.get("defaultblock")!=="p"){var s=q.changedNode,r,j,l=o.Selection.DEFAULT_BLOCK_TAG;if(!s.test(l)){s=s.ancestor(l);}r=o.Node.create("<"+l+">"+o.Selection.CURSOR+"</"+l+">");j=new o.Selection();s.insert(r,"after");j.focusCursor(true,false);q.changedEvent.preventDefault();}break;case"keydown":if(o.config.doc.childNodes.length<2){var y=o.config.doc.body.innerHTML;if(y&&y.length<5&&y.toLowerCase()=="<br>"){this._fixFirstPara();}}break;case"backspace-up":case"backspace-down":case"delete-up":if(!g.UA.ie){var h=o.all(f),w,v,n,k,i,m;v=o.one(d);if(h.item(0)){v=h.item(0);}w=v.one("br");if(w){w.removeAttribute("id");w.removeAttribute("class");}k=o.Selection.getText(v);k=k.replace(/ /g,"").replace(/\n/g,"");m=v.all("img");if(k.length===0&&!m.size()){if(!v.test(e)){this._fixFirstPara();}i=null;if(q.changedNode&&q.changedNode.test(e)){i=q.changedNode;}if(!i&&x._lastPara&&x._lastPara.inDoc()){i=x._lastPara;}if(i&&!i.test(e)){i=i.ancestor(e);}if(i){if(!i.previous()&&i.get("parentNode")&&i.get("parentNode").test(d)){q.changedEvent.frameEvent.halt();}}}if(g.UA.webkit){if(q.changedNode){v=q.changedNode;if(v.test("li")&&(!v.previous()&&!v.next())){n=v.get("innerHTML").replace("<br>","");if(n===""){if(v.get("parentNode")){v.get("parentNode").replace(o.Node.create("<br>"));q.changedEvent.frameEvent.halt();q.preventDefault();o.Selection.filterBlocks();}}}}}}if(g.UA.gecko){var r=q.changedNode,u=o.config.doc.createTextNode(" ");r.appendChild(u);r.removeChild(u);}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@",{skinnable:false,requires:["editor-base","selection"]});