KISSY.Editor.add("image",function(g){g.addPlugin("image",function(){var j=KISSY,d=j.Editor,q=j.UA,r=j.Node,o=j.Event,k=function(a){return a._4e_name()==="img"&&!/(^|\s+)ke_/.test(a[0].className)&&a},i={},l=d.Utils.addRes,s=d.Utils.destroyRes,m=g.addButton("image",{contentCls:"ke-toolbar-image",title:"\u63d2\u5165\u56fe\u7247",mode:d.WYSIWYG_MODE,offClick:function(){this.call("show")},_updateTip:function(a,c){var e=c.attr("_ke_saved_src")||c.attr("src");a.html(e);a.attr("href",e)},show:function(a,c){this.editor.useDialog("image/dialog",
function(e){e.show(c)})}});l.call(i,m,function(){g.destroyDialog("image/dialog")});d.use("contextmenu",function(){function a(b){var f=new r(b.target);b.halt();k(f)&&m.call("show",null,f)}var c={"\u56fe\u7247\u5c5e\u6027":function(b){b=(b=b.getSelection())&&b.getStartElement();(b=k(b))&&m.call("show",null,b)}};o.on(g.document,"dblclick",a);l.call(i,function(){o.remove(g.document,"dblclick",a)});var e={},h;for(h in c)(function(b){e[b]=function(){c[b](g)}})(h);h=d.ContextMenu.register({editor:g,rules:[k],width:"120px",
funcs:e});l.call(i,h)});d.use("bubbleview",function(){d.BubbleView.register({pluginName:"image",pluginContext:m,editor:g,func:k,init:function(){var a=this,c=a.get("contentEl");c.html('\u56fe\u7247\u7f51\u5740\uff1a   <a class="ke-bubbleview-url" target="_blank" href="#"></a> -     <span class="ke-bubbleview-link ke-bubbleview-change">\u7f16\u8f91</span> -     <span class="ke-bubbleview-link ke-bubbleview-remove">\u5220\u9664</span>');var e=c.one(".ke-bubbleview-url"),h=c.one(".ke-bubbleview-change"),b=c.one(".ke-bubbleview-remove");d.Utils.preventFocus(c);
h.on("click",function(f){a._plugin.call("show",null,a._selectedEl);f.halt()});b.on("click",function(f){var p=a._plugin;if(q.webkit){var n=p.editor.getSelection().getRanges();n&&n[0]&&(n[0].collapse(true)||1)&&n[0].select()}a._selectedEl._4e_remove();a.hide();p.editor.notifySelectionChange();f.halt()});d.Utils.addRes.call(a,h,b);a.on("show",function(){var f=a._selectedEl;f&&a._plugin.call("_updateTip",e,f)})}});l.call(i,function(){d.BubbleView.destroy("image")})});this.destroy=function(){s.call(i)}})},
{attach:false});
