function Style::buildConfigurationForm

Same name in other branches
  1. 10 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Style.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Style::buildConfigurationForm()
  2. 11.x core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Style.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Style::buildConfigurationForm()

File

core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Style.php, line 28

Class

Style
CKEditor 5 Style plugin configuration.

Namespace

Drupal\ckeditor5\Plugin\CKEditor5Plugin

Code

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.