You are here

function hook_tinymce_plugins in TinyMCE 7

Provides a list of TinyMCE plugins.

Each plugin for TinyMCE must provide an array of properties containing information about the plugin. At minimum, plugins must provide a path and file location so that TinyMCE may add the plugin. Available properties for each plugin include:

  • location: Required for all external plugins. String path to the plugin directory relative to the Drupal installation root. Do not include a trailing slash.
  • file: Required for all external plugins. String file name of the plugin in the "location" directory.
  • internal: Boolean value indicating if the plugin is part of the compressed TinyMCE library package and already loaded on all instances. If TRUE, the "location" and "file" properties are not needed.
  • css: An array of CSS files that should be added by TinyMCE. These files are used only when TinyMCE is using an iframe wrapper around its content. If a plugin needs to include CSS for inline and iframe versions, it should add its CSS via TinyMCE's JavaScript TinyMCE.addCss() method.
  • enabled callback: String containing a function name that can determine if this plugin should be enabled based on the current editor configuration. See the hook_tinymce_PLUGIN_plugin_check() function for an example.
  • buttons: An array of buttons that are provided by this plugin. Each button should by keyed by its TinyMCE button name, and should contain an array of button properties, including:

    • label: A human-readable, translated button name.
    • image: An image for the button to be used in the toolbar.
    • image_rtl: If the image needs to have a right-to-left version, specify an alternative file that will be used in RTL editors.
    • image_alternative: If this button does not render as an image, specify an HTML string representing the contents of this button. This alternative will only be used in the administrative section for assembling the toolbar.
    • attributes: An array of HTML attributes which should be added to this button when rendering the button in the administrative section for assembling the toolbar.
    • multiple: Boolean value indicating if this button may be added multiple times to the toolbar. This typically is only applicable for dividers and group indicators.
    • required_tags: If this button requires certain HTML tags to be allowed, specify an array of tags.

Return value

array An array of plugin definitions, keyed by the plugin name.

See also

tinymce_tinymce_plugins()

hook_tinymce_PLUGIN_plugin_check()

1 function implements hook_tinymce_plugins()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

tinymce_tinymce_plugins in ./tinymce.module
Implements hook_tinymce_plugins().
1 invocation of hook_tinymce_plugins()
tinymce_plugins in ./tinymce.module
Retrieves the full list of installed TinyMCE plugins.

File

./tinymce.api.php, line 61
Documentation for TinyMCE module APIs.

Code

function hook_tinymce_plugins() {

  // The drupalcaption plugin provides consistent behaviors for image captions.
  $plugins['myplugin'] = array(
    'path' => drupal_get_path('module', 'mymodule') . '/js/myplugin',
    'file' => 'plugin.js',
    'css' => array(
      drupal_get_path('module', 'mymodule') . '/css/myplugin.css',
    ),
    'enabled callback' => 'mymodule_myplugin_plugin_check',
  );
  return $plugins;
}