You are here

public function StylesCombo::settingsForm in Zircon Profile 8

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

Returns a settings form to configure this CKEditor plugin.

If the plugin's behavior depends on extensive options and/or external data, then the implementing module can choose to provide a separate, global configuration page rather than per-text-editor settings. In that case, this form should provide a link to the separate settings page.

Parameters

array $form: An empty form array to be populated with a configuration form, if any.

\Drupal\Core\Form\FormStateInterface $form_state: The state of the entire filter administration form.

\Drupal\editor\Entity\Editor $editor: A configured text editor object.

Return value

array|FALSE A render array for the settings form, or FALSE if there is none.

Overrides CKEditorPluginConfigurableInterface::settingsForm

File

core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php, line 75
Contains \Drupal\ckeditor\Plugin\CKEditorPlugin\StylesCombo.

Class

StylesCombo
Defines the "stylescombo" plugin.

Namespace

Drupal\ckeditor\Plugin\CKEditorPlugin

Code

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

  // Defaults.
  $config = array(
    'styles' => '',
  );
  $settings = $editor
    ->getSettings();
  if (isset($settings['plugins']['stylescombo'])) {
    $config = $settings['plugins']['stylescombo'];
  }
  $form['styles'] = array(
    '#title' => t('Styles'),
    '#title_display' => 'invisible',
    '#type' => 'textarea',
    '#default_value' => $config['styles'],
    '#description' => 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' => array(
      'library' => array(
        'ckeditor/drupal.ckeditor.stylescombo.admin',
      ),
    ),
    '#element_validate' => array(
      array(
        $this,
        'validateStylesValue',
      ),
    ),
  );
  return $form;
}