You are here

private function CKEditor5::injectPluginSettingsForm in Drupal 10

Injects the CKEditor plugins settings forms as a vertical tabs subform.

Parameters

array &$form: A reference to an associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

\Drupal\editor\EditorInterface $editor: A configured text editor object.

File

core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php, line 478

Class

CKEditor5
Defines a CKEditor 5-based text editor for Drupal.

Namespace

Drupal\ckeditor5\Plugin\Editor

Code

private function injectPluginSettingsForm(array &$form, FormStateInterface $form_state, EditorInterface $editor) : void {
  $definitions = $this->ckeditor5PluginManager
    ->getDefinitions();
  $eventual_editor_and_format = $this
    ->getEventualEditorWithPrimedFilterFormat($form_state, $editor);
  foreach ($definitions as $plugin_id => $definition) {
    if ($definition
      ->isConfigurable() && $this
      ->shouldHaveVisiblePluginSettingsForm($definition, $eventual_editor_and_format)) {
      $plugin = $this->ckeditor5PluginManager
        ->getPlugin($plugin_id, $editor);
      $plugin_settings_form = [];
      $form['plugins'][$plugin_id] = [
        '#type' => 'details',
        '#title' => $definition
          ->label(),
        '#open' => TRUE,
        '#group' => 'editor][settings][plugin_settings',
        '#attributes' => [
          'data-ckeditor5-plugin-id' => $plugin_id,
        ],
      ];
      $form['plugins'][$plugin_id] += $plugin
        ->buildConfigurationForm($plugin_settings_form, $form_state);
    }
  }
}