public function Style::buildConfigurationForm in Drupal 10
File
- core/
modules/ ckeditor5/ src/ Plugin/ CKEditor5Plugin/ Style.php, line 28
Class
- Style
- CKEditor 5 Style plugin configuration.
Namespace
Drupal\ckeditor5\Plugin\CKEditor5PluginCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['styles'] = [
'#title' => $this
->t('Styles'),
'#type' => 'textarea',
'#description' => $this
->t('A list of classes that will be provided in the "Style" dropdown. Enter one or more classes on each line in the format: element.classA.classB|Label. Example: h1.title|Title. Advanced example: h1.fancy.title|Fancy title.<br />These styles should be available in your theme\'s CSS file.'),
];
if (!empty($this->configuration['styles'])) {
$as_selectors = '';
foreach ($this->configuration['styles'] as $style) {
[
$tag,
$classes,
] = self::getTagAndClasses(HTMLRestrictions::fromString($style['element']));
$as_selectors .= sprintf("%s.%s|%s\n", $tag, implode('.', $classes), $style['label']);
}
$form['styles']['#default_value'] = $as_selectors;
}
return $form;
}