You are here

public function StylesCombo::settingsForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php \Drupal\ckeditor\Plugin\CKEditorPlugin\StylesCombo::settingsForm()
  2. 9 core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php \Drupal\ckeditor\Plugin\CKEditorPlugin\StylesCombo::settingsForm()

File

core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php, line 70

Class

StylesCombo
Defines the "stylescombo" plugin.

Namespace

Drupal\ckeditor\Plugin\CKEditorPlugin

Code

public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {

  // Defaults.
  $config = [
    'styles' => '',
  ];
  $settings = $editor
    ->getSettings();
  if (isset($settings['plugins']['stylescombo'])) {
    $config = $settings['plugins']['stylescombo'];
  }
  $form['styles'] = [
    '#title' => $this
      ->t('Styles'),
    '#title_display' => 'invisible',
    '#type' => 'textarea',
    '#default_value' => $config['styles'],
    '#description' => $this
      ->t('A list of classes that will be provided in the "Styles" 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.'),
    '#attached' => [
      'library' => [
        'ckeditor/drupal.ckeditor.stylescombo.admin',
      ],
    ],
    '#element_validate' => [
      [
        $this,
        'validateStylesValue',
      ],
    ],
  ];
  return $form;
}