/**
  * Builds the "contentsCss" configuration part of the CKEditor JS settings.
  *
  * @see getJSSettings()
  *
  * @param \Drupal\editor\Entity\Editor $editor
  *   A configured text editor object.
  * @return array
  *   An array containing the "contentsCss" configuration.
  */
 public function buildContentsCssJSSetting(EditorEntity $editor)
 {
     $css = array(drupal_get_path('module', 'ckeditor') . '/css/ckeditor-iframe.css', drupal_get_path('module', 'system') . '/css/system.module.css');
     $this->moduleHandler->alter('ckeditor_css', $css, $editor);
     $css = array_merge($css, _ckeditor_theme_css());
     $css = array_map('file_create_url', $css);
     return array_values($css);
 }
 /**
  * Tests loading of theme's CKEditor stylesheets defined in the .info file.
  */
 function testExternalStylesheets()
 {
     $theme_handler = \Drupal::service('theme_handler');
     // Case 1: Install theme which has an absolute external CSS URL.
     $theme_handler->install(['test_ckeditor_stylesheets_external']);
     $theme_handler->setDefault('test_ckeditor_stylesheets_external');
     $expected = ['https://fonts.googleapis.com/css?family=Open+Sans'];
     $this->assertIdentical($expected, _ckeditor_theme_css('test_ckeditor_stylesheets_external'));
     // Case 2: Install theme which has an external protocol-relative CSS URL.
     $theme_handler->install(['test_ckeditor_stylesheets_protocol_relative']);
     $theme_handler->setDefault('test_ckeditor_stylesheets_protocol_relative');
     $expected = ['//fonts.googleapis.com/css?family=Open+Sans'];
     $this->assertIdentical($expected, _ckeditor_theme_css('test_ckeditor_stylesheets_protocol_relative'));
     // Case 3: Install theme which has a relative CSS URL.
     $theme_handler->install(['test_ckeditor_stylesheets_relative']);
     $theme_handler->setDefault('test_ckeditor_stylesheets_relative');
     $expected = ['core/modules/system/tests/themes/test_ckeditor_stylesheets_relative/css/yokotsoko.css'];
     $this->assertIdentical($expected, _ckeditor_theme_css('test_ckeditor_stylesheets_relative'));
 }
Example #3
0
 /**
  * Builds the "contentsCss" configuration part of the CKEditor JS settings.
  *
  * @see getJSSettings()
  *
  * @param \Drupal\editor\Entity\Editor $editor
  *   A configured text editor object.
  * @return array
  *   An array containing the "contentsCss" configuration.
  */
 public function buildContentsCssJSSetting(Editor $editor)
 {
     $css = array(drupal_get_path('module', 'ckeditor') . '/css/ckeditor-iframe.css', drupal_get_path('module', 'system') . '/css/components/align.module.css');
     $this->moduleHandler->alter('ckeditor_css', $css, $editor);
     // Get a list of all enabled plugins' iframe instance CSS files.
     $plugins_css = array_reduce($this->ckeditorPluginManager->getCssFiles($editor), function ($result, $item) {
         return array_merge($result, array_values($item));
     }, array());
     $css = array_merge($css, $plugins_css);
     $css = array_merge($css, _ckeditor_theme_css());
     $css = array_map('file_create_url', $css);
     $css = array_map('file_url_transform_relative', $css);
     return array_values($css);
 }