Redactor.add("plugin","video",{translations:{en:{video:"Video","video-html-code":"Video Embed Code or Youtube/Vimeo Link"}},modals:{video:'
'},init:function(e){this.app=e,this.lang=e.lang,this.opts=e.opts,this.toolbar=e.toolbar,this.component=e.component,this.insertion=e.insertion,this.inspector=e.inspector},onmodal:{video:{opened:function(e,i){i.getField("video").focus()},insert:function(e,i){var t=i.getData();this._insert(t)}}},oncontextbar:function(e,i){var t=this.inspector.parse(e.target);if(t.isComponentType("video")){var o=t.getComponent(),n={remove:{title:this.lang.get("delete"),api:"plugin.video.remove",args:o}};i.set(e,o,n,"bottom")}},start:function(){var e={title:this.lang.get("video"),api:"plugin.video.open"};this.toolbar.addButtonAfter("image","video",e).setIcon('')},open:function(){var e={title:this.lang.get("video"),width:"600px",name:"video",handle:"insert",commands:{insert:{title:this.lang.get("insert")},cancel:{title:this.lang.get("cancel")}}};this.app.api("module.modal.build",e)},remove:function(e){this.component.remove(e)},_insert:function(e){if(this.app.api("module.modal.close"),""!==e.video.trim()&&(e.video=this._matchData(e.video),this._isVideoIframe(e.video))){var i=this.component.create("video",e.video);this.insertion.insertHtml(i)}},_isVideoIframe:function(e){return null!==e.match(/]?)>([\w\W]*?)<\/p>/gi,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,function(e,i){return-1===o.indexOf(i.toLowerCase())?"":e})}else e.match(this.opts.regex.youtube)?e=e.replace(this.opts.regex.youtube,i+"//www.youtube.com/embed/$1"+t):e.match(this.opts.regex.vimeo)&&(e=e.replace(this.opts.regex.vimeo,i+"//player.vimeo.com/video/$2"+t));return e}});