ckeditor5.module
Same filename and directory in other branches
File
-
core/
modules/ ckeditor5/ ckeditor5.module
View source
<?php
/**
* @file
* Implements hooks for the CKEditor 5 module.
*/
declare (strict_types=1);
use Drupal\ckeditor5\Hook\Ckeditor5Hooks;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageManagerInterface;
/**
* Form submission handler for filter format forms.
*
* @deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. Use
* \Drupal\ckeditor5\Hook\Ckeditor5Hooks::filterFormatEditFormSubmit()
* instead.
*
* @see https://www.drupal.org/node/3566774
*/
function ckeditor5_filter_format_edit_form_submit(array $form, FormStateInterface $form_state) : void {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. Use \\Drupal\\ckeditor5\\Hook\\Ckeditor5Hooks::filterFormatEditFormSubmit() instead. See https://www.drupal.org/node/3566774', E_USER_DEPRECATED);
\Drupal::service(Ckeditor5Hooks::class)->filterFormatEditFormSubmit($form, $form_state);
}
/**
* AJAX callback handler for filter_format_form().
*
* Used instead of editor_form_filter_admin_form_ajax from the editor module.
*
* @deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. Use
* \Drupal\ckeditor5\Hook\Ckeditor5Hooks::updateCkeditor5HtmlFilter() instead.
*
* @see https://www.drupal.org/node/3566774
*/
function _update_ckeditor5_html_filter(array $form, FormStateInterface $form_state) {
@trigger_error(__FUNCTION__ . 'is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. Use \\Drupal\\ckeditor5\\Hook\\Ckeditor5Hooks::updateCkeditor5HtmlFilter() instead. See https://www.drupal.org/node/3566774', E_USER_DEPRECATED);
return \Drupal::service(Ckeditor5Hooks::class)->updateCkeditor5HtmlFilter($form, $form_state);
}
/**
* Returns a list of language codes supported by CKEditor 5.
*
* @param string|bool $lang
* The Drupal langcode to match.
*
* @return array|mixed|string
* The associated CKEditor 5 langcode.
*
* @deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Use
* \Drupal\Core\Language\LanguageManagerInterface instead.
*
* @see https://www.drupal.org/node/3531600
*/
function _ckeditor5_get_langcode_mapping($lang = FALSE) {
@trigger_error('_ckeditor5_get_langcode_mapping() is deprecated in drupal:11.3.0 and is removed from drupal:13.0.0. Use \\Drupal\\Core\\Language\\LanguageManagerInterface instead. See https://www.drupal.org/node/3531600', E_USER_DEPRECATED);
if ($lang) {
return \Drupal::service(LanguageManagerInterface::class)->getMapping($lang);
}
else {
return \Drupal::service(LanguageManagerInterface::class)->getMappings();
}
}
/**
* Retrieves the default theme's CKEditor 5 stylesheets.
*
* Themes may specify CSS files for use within CKEditor 5 by including a
* "ckeditor5-stylesheets" key in their .info.yml file.
*
* @code
* ckeditor5-stylesheets:
* - css/ckeditor.css
* @endcode
*
* @return string[]
* A list of paths to CSS files.
*
* @deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. No
* replacement is provided.
*
* @see https://www.drupal.org/node/3566774
*/
function _ckeditor5_theme_css($theme = NULL) : array {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:12.0.0. No replacement is provided. See https://www.drupal.org/node/3566774', E_USER_DEPRECATED);
$css = [];
if (!isset($theme)) {
$theme = \Drupal::config('system.theme')->get('default');
}
if (isset($theme) && $theme_path = \Drupal::service('extension.list.theme')->getPath($theme)) {
$info = \Drupal::service('extension.list.theme')->getExtensionInfo($theme);
if (isset($info['ckeditor5-stylesheets']) && $info['ckeditor5-stylesheets'] !== FALSE) {
$css = $info['ckeditor5-stylesheets'];
foreach ($css as $key => $url) {
// CSS URL is external or relative to Drupal root.
if (UrlHelper::isExternal($url) || $url[0] === '/') {
$css[$key] = $url;
}
else {
$css[$key] = '/' . $theme_path . '/' . $url;
}
}
}
if (isset($info['base theme'])) {
$css = array_merge(_ckeditor5_theme_css($info['base theme']), $css);
}
}
return $css;
}
Functions
| Title | Deprecated | Summary |
|---|---|---|
| ckeditor5_filter_format_edit_form_submit | in drupal:11.4.0 and is removed from drupal:12.0.0. Use \Drupal\ckeditor5\Hook\Ckeditor5Hooks::filterFormatEditFormSubmit() instead. |
Form submission handler for filter format forms. |
| _ckeditor5_get_langcode_mapping | in drupal:11.3.0 and is removed from drupal:12.0.0. Use \Drupal\Core\Language\LanguageManagerInterface instead. |
Returns a list of language codes supported by CKEditor 5. |
| _ckeditor5_theme_css | in drupal:11.4.0 and is removed from drupal:12.0.0. No replacement is provided. |
Retrieves the default theme's CKEditor 5 stylesheets. |
| _update_ckeditor5_html_filter | in drupal:11.4.0 and is removed from drupal:12.0.0. Use \Drupal\ckeditor5\Hook\Ckeditor5Hooks::updateCkeditor5HtmlFilter() instead. |
AJAX callback handler for filter_format_form(). |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.