function StylesCombo::settingsForm

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

Overrides CKEditorPluginConfigurableInterface::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;
}

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