function tinymce_add_settings in TinyMCE 7
Editor JS settings callback; Add Aloha settings to the page for a format.
Parameters
$editor: The editor object for which Aloha is adding its settings.
$format: The filter format object for which Aloha is adding its settings.
$existing_settings: Settings that have already been added to the page by filters.
1 call to tinymce_add_settings()
- tinymce_wysiwyg_settings in includes/
tinymce_extended.inc - Return JavaScript settings that should be passed to the WYSIWYG editor.
1 string reference to 'tinymce_add_settings'
- tinymce_editor_info in ./
tinymce.module - Implements hook_editor_info().
File
- ./
tinymce.module, line 580
Code
function tinymce_add_settings($editor, $format, $existing_settings) {
global $language;
// Loop through all available plugins and check to see if it has been
// explicitly enabled. At the same time, associate each plugin with its
// buttons (if any) so we can check if the plugin should be enabled implicitly
// based on the toolbar.
$plugin_info = tinymce_plugins();
$external_plugins = array();
$external_css = array();
$all_buttons = array();
foreach ($plugin_info as $plugin_name => $plugin) {
// Check if this plugin should be enabled.
if (isset($plugin['enabled callback'])) {
if ($plugin['enabled callback'] === TRUE || $plugin['enabled callback']($editor, $plugin_name) && !empty($plugin['path'])) {
$external_plugins[$plugin_name]['file'] = $plugin['file'];
$external_plugins[$plugin_name]['path'] = $plugin['path'];
if (isset($plugin['css'])) {
$external_css = array_merge($external_css, $plugin['css']);
}
}
}
// Associate each plugin with its button.
if (isset($plugin['buttons'])) {
if (empty($plugin['internal'])) {
foreach ($plugin['buttons'] as $button_name => &$button) {
$button['plugin'] = $plugin;
$button['plugin']['name'] = $plugin_name;
unset($button['plugin']['buttons']);
}
}
$all_buttons = array_merge($all_buttons, $plugin['buttons']);
}
}
// Change the toolbar separators into groups and record needed plugins based
// on use in the toolbar.
$toolbar = array();
foreach ($editor->settings['toolbar'] as $row_number => $row) {
$button_group = array();
foreach ($row as $button_name) {
if ($button_name === '|') {
$toolbar[] = $button_group;
$button_group = array();
}
else {
// Sanity check that the button exists in our installation.
if (isset($all_buttons[$button_name])) {
$button_group['items'][] = $button_name;
// Keep track of the needed plugin for this button, if any.
if (isset($all_buttons[$button_name]['plugin']['path'])) {
$plugin_name = $all_buttons[$button_name]['plugin']['name'];
$external_plugin = $all_buttons[$button_name]['plugin'];
$external_plugins[$plugin_name]['file'] = $external_plugin['file'];
$external_plugins[$plugin_name]['path'] = $external_plugin['path'];
if (isset($external_plugin['css'])) {
$external_css = array_merge($external_css, $external_plugin['css']);
}
}
}
}
}
$toolbar[] = $button_group;
$toolbar[] = '/';
}
// Collect a list of CSS files to be added to the editor instance.
$css = array(
drupal_get_path('module', 'tinymce') . '/css/tinymce.css',
drupal_get_path('module', 'tinymce') . '/css/tinymce-iframe.css',
);
$css = array_merge($css, $external_css, _tinymce_theme_css());
drupal_alter('tinymce_css', $css, $editor, $format);
// Convert all paths to be relative to root.
foreach ($css as $key => $css_path) {
$css[$key] = base_path() . $css_path;
}
// Initialize reasonable defaults that provide expected basic bahvior.
$settings = array(
'toolbar' => $toolbar,
'extraPlugins' => implode(',', array_keys($external_plugins)),
'removePlugins' => 'image',
//'forcePasteAsPlainText' => TRUE,
'contentsCss' => array_values($css),
'pasteFromWordPromptCleanup' => TRUE,
'indentClasses' => array(
'indent1',
'indent2',
'indent3',
),
'justifyClasses' => array(
'align-left',
'align-center',
'align-right',
'align-justify',
),
'coreStyles_underline' => array(
'element' => 'span',
'attributes' => array(
'class' => 'underline',
),
),
'format_tags' => implode(';', $editor->settings['format_list']),
'removeDialogTabs' => 'image:Link;image:advanced;link:advanced',
'language' => isset($language->language) ? $language->language : '',
'resize_dir' => 'vertical',
);
// These settings are used specifically by Drupal.
$settings['externalPlugins'] = $external_plugins;
return $settings;
}