YUI.add("editor-bidi",function(E,e){var h=function(){h.superclass.constructor.apply(this,arguments)},g="host",p="dir",o="bidiContextChange",t="style";E.extend(h,E.Base,{lastDirection:null,firstEvent:null,_checkForChange:function(){var e,t,i=this.get(g),n=i.getInstance(),r=new n.EditorSelection;r.isCollapsed?(e=h.blockParent(r.focusNode,!1,n.EditorSelection.ROOT))&&(t=e.getStyle("direction"))!==this.lastDirection&&(i.fire(o,{changedTo:t}),this.lastDirection=t):(i.fire(o,{changedTo:"select"}),this.lastDirection=null)},_afterNodeChange:function(e){(this.firstEvent||h.EVENTS[e.changedType])&&(this._checkForChange(),this.firstEvent=!1)},_afterMouseUp:function(){this._checkForChange(),this.firstEvent=!1},initializer:function(){var e=this.get(g);this.firstEvent=!0,e.after("nodeChange",E.bind(this._afterNodeChange,this)),e.after("dom:mouseup",E.bind(this._afterMouseUp,this))}},{EVENTS:{"backspace-up":!0,"pageup-up":!0,"pagedown-down":!0,"end-up":!0,"home-up":!0,"left-up":!0,"up-up":!0,"right-up":!0,"down-up":!0,"delete-up":!0},BLOCKS:E.EditorSelection.BLOCKS,DIV_WRAPPER:"
",blockParent:function(e,t,i){var n,r,o=e;return i=i||E.EditorSelection.ROOT,o||(o=i),o.test(h.BLOCKS)||(o=o.ancestor(h.BLOCKS)),t&&o.compareTo(i)&&(n=E.Node.create(h.DIV_WRAPPER),o.get("children").each(function(e,t){0===t?r=e:n.append(e)}),r.replace(n),n.prepend(r),o=n),o},_NODE_SELECTED:"bidiSelected",addParents:function(e,t){var i,n,r;for(tester=function(e){if(!e.getData(h._NODE_SELECTED))return!(r=!1)},t=t||E.EditorSelection.ROOT,i=0;i