function quickedit_library_info_alter in Drupal 10
Same name and namespace in other branches
- 8 core/modules/quickedit/quickedit.module \quickedit_library_info_alter()
- 9 core/modules/quickedit/quickedit.module \quickedit_library_info_alter()
Implements hook_library_info_alter().
Includes additional stylesheets defined by the admin theme to allow it to customize the Quick Edit toolbar appearance.
An admin theme can specify CSS files to make the front-end administration experience of in-place editing match the administration experience in the back-end.
The CSS files can be specified via the "edit_stylesheets" property in the .info.yml file:
quickedit_stylesheets:
-css / quickedit . css;
File
- core/
modules/ quickedit/ quickedit.module, line 80 - Provides in-place content editing functionality for fields.
Code
function quickedit_library_info_alter(&$libraries, $extension) {
if ($extension === 'quickedit' && isset($libraries['quickedit'])) {
$theme = Drupal::config('system.theme')
->get('admin');
// First let the base theme modify the library, then the actual theme.
$alter_library = function (&$library, $theme) use (&$alter_library) {
/** @var \Drupal\Core\Extension\ThemeExtensionList $theme_list */
$theme_list = \Drupal::service('extension.list.theme');
if (!empty($theme) && ($theme_path = $theme_list
->getPath($theme))) {
$info = $theme_list
->getExtensionInfo($theme);
// Recurse to process base theme(s) first.
if (isset($info['base theme'])) {
$alter_library($library, $info['base theme']);
}
if (isset($info['quickedit_stylesheets'])) {
foreach ($info['quickedit_stylesheets'] as $path) {
$library['css']['theme']['/' . $theme_path . '/' . $path] = [];
}
}
}
};
$alter_library($libraries['quickedit'], $theme);
}
$moduleHandler = \Drupal::moduleHandler();
if ($moduleHandler
->moduleExists('ckeditor5')) {
$libraries['drupal.ckeditor5']['dependencies'][] = 'quickedit/quickedit.ckeditor5-temporary-work-around';
}
}