Created
December 3, 2016 08:55
-
-
Save carlodaniele/7ffcd63b33c01d4284b52ad0866a4045 to your computer and use it in GitHub Desktop.
A TinyMCE plugin which adds a custom dropdown menu.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var languages = ['css', 'php', 'html', 'javascript']; | |
tinymce.PluginManager.add( 'prism', function( editor ){ | |
var items = []; | |
tinymce.each( languages, function( languageName ){ | |
items.push({ | |
text: languageName, | |
onclick: function(){ | |
var content = tinyMCE.activeEditor.selection.getContent(); | |
editor.insertContent( '<pre><code class="language-' + languageName + '">' + content + '</code></pre>' ); | |
} | |
}); | |
}); | |
editor.addButton( 'prism', { | |
type: 'menubutton', | |
text: 'Prism', | |
icon: 'code', | |
menu: items | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment