While working on #328116: Safari Plugin TinyMCE 6.x, I discovered that some plugins of TinyMCE 2

- either have been removed (f.e. "devkit", "zoom"),
- moved into TinyMCE core ("cleanup"),
- moved into TinyMCE's default plugins ("blockquote"),
- or moved into other plugins ("flash" -> "media").

Also, TinyMCE 3 ships with new plugins ("pagebreak", "safari", "spellchecker").
Lastly, button names as well as plugin configuration options can change between versions.

This effectively means, the current method to define internal editor plugins is not sufficient. Plugins and buttons have a lifetime (min/max version), and their definition might look completely different for a different editor version.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ryanbach’s picture

For Tinymce it is as easy as looking in the tinymce/jscripts/tiny_mce/plugins/ directory...

mr.andrey’s picture

So how do you define plugins here? In the Tinymce module there was plugin_reg.php.

I want to enable the "media" plugin.

Thanks,
Andrey.

budda’s picture

If looks like you need to make a module and implement the hook:

function wysiwyg_wysiwyg_plugin($editor, $version) {
  switch ($editor) {
    case 'tinymce':
mr.andrey’s picture

Found the answer here:
http://drupal.org/node/363632

richard.e.morton’s picture

-- have posted here as it has been marked as duplicate of this item.

Hi I have a new D6 site with wysiwyg, tinymce and image assist (with image assist button).

All wors fine unless I enable the flash button on the inputformat / wysiwyg page, then the RTE buttons no longer appear in the create content form for the text area. As soon as I disable the flash button all returns to normal.

Thanks

Richard

alexromao’s picture

FileSize
5.2 KB

As the flash plug-in is now the media plug-in and some of the "buttons" like pagebreake or spellcheck are missing,
i edited the tinymce api and added the missing buttons for these plug-ins.

Replace the tinymce.inc in your drupal/sites/all/modules/wysiwyg/editors folder with the one i attached
and you'll see the option for the media "button" on your interface.

New buttons are :
Media, Pagebreak, Spell Checker, Invisible Characters

davideads’s picture

Budda is correct -- this is possible via the wysiwyg_plugin hook.

After a fair amount of looking at the code and (admittedly incorrect) documentation, I found this incantation to work fine -- this is loading a 3rd party plugin for TinyMCE as well as the Noneditable plugin that is part of the standard TInyMCE package.

/**
 * Implementation of hook_wywiwyg_plugin().
 */
function mymodule_wysiwyg_plugin($editor, $version=0) {
  $plugins = array();
  switch ($editor) {
    case 'tinymce':
      if ($version > 3) {
        $plugins['atomic'] = array(
          'type' => 'external',
          'title' => t('Atomic selection plugin'),
          'description' => t('This plugin forces a selection up to the outer container of a given element.  It is available via the third party repository maintained by MoxieCode on SourceForge.'),
          'extensions' => array('atomic' => t('Atomic Selection')),
          'path' => drupal_get_path('module', 'mymodule') .'/rte-plugins/atomic/editor_plugin.js', 
          'url' => 'http://sourceforge.net/tracker/index.php?func=detail&aid=2519211&group_id=103281&atid=738747',
          'load' => TRUE,
        );
        $plugins['noneditable'] = array(
          'path' => drupal_get_path('module', 'wysiwyg') .'/tinymce/jscripts/tiny_mce/plugins/noneditable/editor_plugin.js',
          'extensions' => array('noneditable' => t('Noneditable')),
          'load' => TRUE,
        );
      }
      break;
  }
  return $plugins;
}

Note that neither of the above examples provides buttons.

MMachnik’s picture

+1, out of the box version needs modifying to enable these plugins so would be nice to have it in there already. Thanks!

eyecon-1’s picture

L3X's version of the inc file works with the latest version, in my case 6.x-2.x-dev. However, you must comment out the pagebreak - lines 473 to 479,

Question: Why is this not included in the distribution? As provided, spellcheck will not work.

rickvug’s picture

This is an excellent idea. If this does get implemented, please don't overlook support for a libraries directory at the root level (/libraries). The use case is that Drupal distros want to place all standard code outside of the /sites directory, which may not even exist in their base install. This pattern would be consistent with the modules and themes directories.

rickvug’s picture

Whoops... wrong issue thread. Last comment was meant for #320562.

Avatar’s picture

I tried L3X inc. file and the new buttons/plugins appeared and seems to be working ,however I first get an error line that repeats itself like hundreds of times whether in the admin. back end or the edit node page.

The error line says "Warning: Unexpected character in input: ' ......../sites/all/modules/wysiwyg/editors/tinymce.inc on line 556

I tried doing as eyecon said, though am not sure I did it right since I know nothing about coding. Can someone please help me by writing down exactly the lines of codes that need to be commented out/deleted ... if that's the solution for the error I'm getting??

I am using wisywig 6.x-1.2 , Drupal 6.10 (didn't update yet) and TinyMCE 3.2.4.1

..and why haven't this media plugin be added to the module, it has been there for a year now!!

iva2k’s picture

Just to let people know - I've created Wysiwyg SpellCheck module that enables TinyMCE spellchecker plugin. It may be just what you need, until there is a better approach to Wysiwyg plugins.

quiller’s picture

Similar to iva2k's module, I've created a Wysiwyg Media module that makes the media plugin available for TinyMCE. I'm applying for a CVS account so I can create a project page, but for now the code is available here for anyone that is interested:


/**
 * @description wysiwyg_media is a plugin for Wysiwyg API
 */

/**
 * Implementation of hook_help().
 */
function wysiwyg_spellcheck_help($path, $arg) {
  if ($path == 'admin/modules#description') {
    return t('Enables TinyMCE media plugin in Wysiwyg API.');
  }
}

/**
* Implementation of hook_wysiwyg_plugin().
*/
function wysiwyg_media_wysiwyg_plugin($editor, $version) {
  switch ($editor) {
    case 'tinymce':
      if ($version > 3) {
        return array(
          'media' => array(
            'path' => $editor['library path'] .'/plugins/media',
            'buttons' => array('media' => t('Insert media')),
            'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/media',
            'internal' => TRUE,
            'load' => TRUE,
          ),
        );
      }
  }
}

Edit: the full code is attached in a tarball below.

quiller’s picture

FileSize
30 KB
sun’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev

@quiller: Download the latest development snapshot and you're done.

sbatmc’s picture

I just downloaded and installed the latest WYSIWYG API module and it didn't seem to solve the problem - the TinyMCE editor (tinymce_3_2_4_1) still disappears when I enable the Flash button. Any help is appreciated!!

Nevermind, I downloaded Quiller's wysiwyg_media.tar_.gz above, and it works great, thanks! Do you think that TinyMCE will fix this out of the box on the next version that they release of tinymce?

sun’s picture

@sbatmc: You should not be able to enable the "Flash" button in the first place with the latest development snapshot. Note that this is not the "alpha" release, but the development snapshot (below).

quiller’s picture

@sbatmc: The Flash plugin is deprecated entirely. You should be enabling the Media plugin/button instead.

@sun: Thanks for the tip. I'll leave that file around in case somebody wants to use the Media plugin with the stable release.

sun’s picture

The "development snapshot" I mentioned in #16 has turned into a stable release in the meantime. If you did not update already, you are highly encouraged to do so.