This project has moved. For the latest updates, please go here.

embed youtube button

Jan 23, 2015 at 6:58 PM
Hi there,
if anyone was interested, here is a custom toolbar button for youtube:
   [{
                        // YOUTUBE EMBED BUTTON
                        css: "youtube", //style it with "div.jHtmlArea .ToolBar ul li a.youtube{...}" in style/jHtmlArea.css
                        text: "add YouTube video",
                        action: function( event ){
                        x = prompt("YouTube URL address:", "");
                        //strip vid id
                        var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
                        var match = x.match(regExp);
                        if (match && match[2].length == 11) {
                        this.pasteHTML('<iframe width="420" height="315" src="//www.youtube-nocookie.com/embed/'+match[2]+'" frameborder="0" allowfullscreen></iframe>');
                        } else {
                        alert('error');
                        }
                                                }          
                           }],