From 9e2abbda8e7ddbe149f29650ccf808736e05ab19 Mon Sep 17 00:00:00 2001 From: indigoxela Date: Sat, 5 Oct 2024 09:25:29 +0200 Subject: [PATCH] Issue #135: Add importcss feature for styles dropdown --- tinymce.admin.inc | 2 +- tinymce.module | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tinymce.admin.inc b/tinymce.admin.inc index 333a54a..1fdca5e 100644 --- a/tinymce.admin.inc +++ b/tinymce.admin.inc @@ -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.
If a file is named tinymce-styles-dropdown.css, this file additionally gets parsed for items to append to the toolbar styles dropdown.'), ); $elements['tabs']['image_browser'] = array( diff --git a/tinymce.module b/tinymce.module index a417c54..ece1192 100644 --- a/tinymce.module +++ b/tinymce.module @@ -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();