You are here

public function Alignment::buildConfigurationForm in Drupal 10

Form for choosing which alignment types are available.

File

core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/Alignment.php, line 51

Class

Alignment
CKEditor 5 Alignment plugin.

Namespace

Drupal\ckeditor5\Plugin\CKEditor5Plugin

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form['enabled_alignments'] = [
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Enabled Alignments'),
    '#description' => $this
      ->t('These are the alignment types that will appear in the alignment dropdown.'),
  ];
  foreach ($this
    ->getPluginDefinition()
    ->getCKEditor5Config()['alignment']['options'] as $alignment_option) {
    $name = $alignment_option['name'];
    $form['enabled_alignments'][$name] = [
      '#type' => 'checkbox',
      '#title' => $this
        ->t($name),
      '#return_value' => $name,
      '#default_value' => in_array($name, $this->configuration['enabled_alignments'], TRUE) ? $name : NULL,
    ];
  }
  return $form;
}