-1

I am trying to create a custom plugin for TinyMCE 3.5.9. I have a module that is adding it to the WYSIWYG profile, which can be checked. That works. But when I load a page, the custom button does not appear on the WYSIWYG.

The plugin is there in the background though, and I can even fire it in the console using this command: tinyMCE.activeEditor.execCommand('mcePullQuotes');

So the code is being loaded and initialized. Just the button is not appearing. Been banging my head.

This code is pretty much cribbed from the example code in the Jscript/plugins example, and I don't see much different going on in other plugins. There are no console errors.

(function() {
  tinymce.PluginManager.requireLangPack('pullquotes');    
  tinymce.create('tinymce.plugins.PullQuotesPlugin', {
    init : function(ed, url) {

      tinyMCE.activeEditor.execCommand('mcePullQuote');
      ed.addCommand('mcePullQuotes', function() {
        ed.windowManager.open({
          file : url + '/dialog.htm',
          width : 480 + parseInt(ed.getLang('style.delta_width', 0)),
          height : 340 + parseInt(ed.getLang('style.delta_height', 0)),
          inline : 1
        }, {
          plugin_url : url, // Plugin absolute URL
          some_custom_arg : 'custom arg' // Custom argument
        });
      });

      ed.addButton('pullquotes', {
        title : 'PullQuotes',
        text: 'PQ',
        cmd : 'mcePullQuotes',
        icon: false,
        image : url + '/img/example.gif'
      });

    },

    getInfo : function() {
      return {
        longname : 'Pull Quotes plugin',
        author : 'Adrian Cotter',
        authorurl : 'adrian.cotter@sierraclub.org',
        infourl : 'http://www.sierraclub.org',
        version : "1.0"
      };
    }
  });

  tinymce.PluginManager.add('pullquotes', tinymce.plugins.PullQuotesPlugin);
})();

UPDATE:

So one problem was this... I had this in my module code, which is where the button was showing up in config from, and how the code was being loaded.

'extensions' => array(
  'internal_name_of_myplugin' => t('Example'),
),

BUT... I removed that and replaced it with this

'buttons' => array('pullquotes' => t('Pull Quotes')),

This appears in the profile config -- but nothing is loading now. No button, and no JS this time. Path does not seem to be an issue.

  • No console error? – Gulok Mar 21 '17 at 4:08
  • There are no console errors. – Adrained Mar 21 '17 at 17:34
0

I was able to get the button working. Through 2 things in my module.

  1. 'buttons' => array('pullquotes' => t('Pull Quotes')),
  2. 'path' => 'sites/all/libraries/tinymce_plugins/pullquotes',

It seems that the various methods I was using to get the path, were giving the whole URL /sites/all/libraries/tinymce_plugins/pullquotes So when I put it in as an absolute, and then removed the proceeding / everything worked.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.