tinymce.wysiwyg.inc in TinyMCE 7
Provides all integration hooks with WYSIWYG module.
This file is always included on all requests, as it contains several hooks. It is kept separate from the main module file to maintain compatibility with the Drupal 8 version, which does not require any of these hooks.
File
includes/tinymce.wysiwyg.incView source
<?php
/**
* @file
* Provides all integration hooks with WYSIWYG module.
*
* This file is always included on all requests, as it contains several hooks.
* It is kept separate from the main module file to maintain compatibility
* with the Drupal 8 version, which does not require any of these hooks.
*/
/**
* Implements hook_wysiwyg_include_directory().
*/
function tinymce_wysiwyg_include_directory($plugin_type) {
if ($plugin_type === 'editors') {
return 'includes';
}
}
/**
* Implements hook_module_implements_alter().
*/
function tinymce_module_implements_alter(&$implementations, $hook) {
// WYSIWYG module has a namespace conflict with hook_tinymce_plugins().
// This prevents wysiwyg_tinymce_plugins() from being an implementation of
// hook_tinymce_plugins().
if ($hook === 'tinymce_plugins') {
if (isset($implementations['wysiwyg'])) {
unset($implementations['wysiwyg']);
}
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function tinymce_form_wysiwyg_profile_form_alter(&$form, $form_state) {
$profile = $form_state['build_info']['args'][0];
$format = filter_format_load($profile->format);
// Set default settings for the profile.
$tinymce_editor_info = tinymce_editor_info();
$profile->settings = (array) $profile->settings + $tinymce_editor_info['tinymce']['default settings'];
// Hide the basic settings, as they affect behavior of the WYSIWYG module.
$form['basic']['#access'] = FALSE;
// We don't need the toggle link as you can just use the source button.
$form['basic']['default']['#default_value'] = TRUE;
$form['basic']['show_toggle']['#default_value'] = FALSE;
// Remove all the settings we either don't use or replace.
unset($form['buttons'], $form['appearance'], $form['output'], $form['css']);
// Block formats need to exist to prevent notices in WYSIWYG module.
$form['block_formats'] = array(
'#type' => 'value',
'#value' => '',
);
// Add an additional submit handler to clean up our modifications.
// This submit handler must be added before tinymce_settings_form() is called
// below, as it adds another submit handler before it.
array_unshift($form['#submit'], 'tinymce_wysiwyg_settings_form_submit');
// Add the TinyMCE specialized form. We place these in "editor_settings" to
// match the Drupal 8 editor.module form structure, which means more
// compatibility in tinymce_settings_form_submit().
$form['editor_settings'] = tinymce_settings_form($form, $form_state, $profile, $format);
$form['editor_settings']['#tree'] = TRUE;
}
/**
* Additional submit handler for the wysiwyg_profile_form().
*/
function tinymce_wysiwyg_settings_form_submit($form, &$form_state) {
// Move the settings back out of the editor_settings parents so they save.
$form_state['values'] = array_merge($form_state['values'], $form_state['values']['editor_settings']);
unset($form_state['values']['editor_settings']);
}
Functions
Name | Description |
---|---|
tinymce_form_wysiwyg_profile_form_alter | Implements hook_form_FORM_ID_alter(). |
tinymce_module_implements_alter | Implements hook_module_implements_alter(). |
tinymce_wysiwyg_include_directory | Implements hook_wysiwyg_include_directory(). |
tinymce_wysiwyg_settings_form_submit | Additional submit handler for the wysiwyg_profile_form(). |