KISSY.Editor.add("justify",function(d){d.addPlugin("justify",function(){var e=KISSY,c=e.Editor,j=c.TripleButton,k=/(-moz-|-webkit-|start|auto)/gi;c={mode:c.WYSIWYG_MODE,offClick:function(){this.call("_change")},onClick:function(){this.call("_change")},_change:function(){var a=this.editor,b=a.getSelection(),l=this.btn.get("state");if(b){var m=b.createBookmarks(),i=b.getRanges(),g,f;a.fire("save");for(var h=i.length-1;h>=0;h--){g=i[h].createIterator();for(g.enlargeBr=true;f=g.getNextParagraph();){f.removeAttr("align");
l==j.OFF?f.css("text-align",this.cfg.v):f.css("text-align","")}}a.notifySelectionChange();b.selectBookmarks(m);a.fire("save")}},selectionChange:function(a){var b=this.btn;a=a.path;a=a.block||a.blockLimit;if(!a||a._4e_name()==="body")b.boff();else(a.css("text-align").replace(k,"")||"left")==this.cfg.v?b.bon():b.boff()}};var n=d.addButton("alignleft",e.mix({contentCls:"ke-toolbar-alignleft",title:"\u5de6\u5bf9\u9f50",v:"left"},c)),o=d.addButton("aligncenter",e.mix({contentCls:"ke-toolbar-aligncenter",title:"\u5c45\u4e2d\u5bf9\u9f50",
v:"center"},c)),p=d.addButton("alignright",e.mix({contentCls:"ke-toolbar-alignright",title:"\u53f3\u5bf9\u9f50",v:"right"},c));this.destroy=function(){n.destroy();o.destroy();p.destroy()}})},{attach:false});
