!function(){var a,b=tinymce.VK,c=tinymce.dom.TreeWalker;tinymce.create("tinymce.plugins.wpView",{init:function(d,e){var f=this;"undefined"!=typeof wp&&wp.mce&&(d.onPreInit.add(function(a){a.schema.addValidElements("div[*],span[*]")}),d.onBeforeSetContent.add(function(a,b){b.content&&(b.content=wp.mce.view.toViews(b.content))}),d.onSetContent.add(function(a,b){wp.mce.view.render(a.getDoc())}),d.onInit.add(function(a){a.selection.onBeforeSetContent.add(function(b,d){var e,g,h=f.getParentView(b.getNode());h&&(!h.nextSibling||f.isView(h.nextSibling)?(g=a.getDoc().createTextNode(""),a.dom.insertAfter(g,h)):(e=new c(h.nextSibling,h.nextSibling),g=e.next()),b.select(g),b.collapse(!0))}),a.selection.onSetContent.add(function(a,b){if(b.context){var c=a.getNode();c.innerHTML&&(c.innerHTML=wp.mce.view.toViews(c.innerHTML),wp.mce.view.render(c))}})}),d.onPostProcess.add(function(a,b){(b.get||b.save)&&b.content&&(b.content=wp.mce.view.toText(b.content))}),d.onNodeChange.addToTop(function(a,b,c,d,e){var g=f.getParentView(c);return g?(f.select(g),!1):void f.deselect()}),d.onKeyDown.addToTop(function(c,d){var e,g,h=d.keyCode;if(a){if(e=f.getParentView(c.selection.getNode()),e!==a)return void f.deselect();(h===b.DELETE||h===b.BACKSPACE)&&(g=wp.mce.view.instance(a))&&(g.remove(),f.deselect()),d.metaKey||d.ctrlKey||h>=112&&123>=h||d.preventDefault()}}))},getParentView:function(a){for(;a;){if(this.isView(a))return a;a=a.parentNode}},isView:function(a){return/(?:^|\s)wp-view-wrap(?:\s|$)/.test(a.className)},select:function(b){b!==a&&(this.deselect(),a=b,wp.mce.view.select(a))},deselect:function(){a&&wp.mce.view.deselect(a),a=null},getInfo:function(){return{longname:"WordPress Views",author:"WordPress",authorurl:"http://wordpress.org",infourl:"http://wordpress.org",version:"1.0"}}}),tinymce.PluginManager.add("wpview",tinymce.plugins.wpView)}();