Skip to content

Commit

Permalink
Issue #135: Add importcss feature for styles dropdown (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
indigoxela authored Oct 5, 2024
1 parent 76189b2 commit f9990b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tinymce.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function _tinymce_settings_form(array &$form, array $form_state, $format) {
'#attributes' => array(
'placeholder' => '/core/themes/basis/css/skin.css',
),
'#description' => t('Add URLs to CSS files, the editor should use to display its content, one file per line.'),
'#description' => t('Add URLs to CSS files, the editor should use to display its content, one file per line.<br>If a file is named <code>tinymce-styles-dropdown.css</code>, this file additionally gets parsed for items to append to the toolbar styles dropdown.'),
);

$elements['tabs']['image_browser'] = array(
Expand Down
10 changes: 10 additions & 0 deletions tinymce.module
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ function _tinymce_js_settings($format, array $existing_settings) {
$options['tiny_options']['skin'] = $settings['tinymce_settings']['skin'];
$options['tiny_options']['content_css'] = _tinymce_get_content_css($settings['tinymce_settings']);

// If that specific file is also part of content CSS, let Tiny parse it.
if (count($options['tiny_options']['content_css']) > 1) {
$parse_file_found = preg_grep('#tinymce-styles-dropdown\.css$#', $options['tiny_options']['content_css']);
if (!empty($parse_file_found)) {
$options['tiny_options']['plugins'] .= ' importcss';
$options['tiny_options']['importcss_file_filter'] = 'tinymce-styles-dropdown.css';
$options['tiny_options']['importcss_append'] = TRUE;
}
}

// Collect additional TinyMCE plugins from hook.
$external_plugins = module_invoke_all('tinymce_external_plugins', $format);
$icon_registry = array();
Expand Down

0 comments on commit f9990b9

Please sign in to comment.