public function StylesCombo::settingsForm in Drupal 9
Same name and namespace in other branches
- 8 core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php \Drupal\ckeditor\Plugin\CKEditorPlugin\StylesCombo::settingsForm()
- 10 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 A render array for the settings form.
Overrides CKEditorPluginConfigurableInterface::settingsForm
File
- core/
modules/ ckeditor/ src/ Plugin/ CKEditorPlugin/ StylesCombo.php, line 70
Class
- StylesCombo
- Defines the "stylescombo" plugin.
Namespace
Drupal\ckeditor\Plugin\CKEditorPluginCode
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;
}