I'm trying to add a custom button to my TinyMCE editor in Wysiwyg on a Drupal 7 install.

I've managed to adapt TinyMCE settings to work in my custom module, like so:

function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
  if ($context['profile']->editor == 'tinymce')
  if ($context['profile']->format == 'filtered_html') {
    $settings['browser_spellcheck'] = TRUE;
    $settings['toolbar'] = "bold italic underline mybutton";

TinyMCE recommends the following (source):

  selector: '#editor',
  toolbar: 'myCustomToolbarButton',
  setup: function (editor) {
    editor.ui.registry.addButton('myCustomToolbarButton', {
      text: 'My Custom Button',
      onAction: function () {
        alert('Button clicked!');

I'm struggling with the "setup: function (editor)" part, which I can't seem to adapt correctly for either Jquery to add to my custom.js or to include in the MyModule code without breaking.

What is the best way to stitch this together? Does it wrap in a array setting? What's the correct syntax?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.