public function FontCKEditorButton::settingsForm in CKEditor Font Size and Family 8
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
- src/
Plugin/ CKEditorPlugin/ FontCKEditorButton.php, line 143
Class
- FontCKEditorButton
- Defines the "font" plugin.
Namespace
Drupal\ckeditor_font\Plugin\CKEditorPluginCode
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
// Defaults.
$config = array(
'font_names' => '',
'font_sizes' => '',
);
$settings = $editor
->getSettings();
if (isset($settings['plugins']['font'])) {
$config = $settings['plugins']['font'];
}
$form['font_names'] = array(
'#title' => $this
->t('Font families'),
'#type' => 'textarea',
'#default_value' => $config['font_names'],
'#description' => $this
->t('Enter fonts on new lines. Fonts must be added with the following syntax:<br><code>Primary font, fallback1, fallback2|Font Label</code>'),
'#element_validate' => array(
array(
$this,
'validateFontValue',
),
),
);
$form['font_sizes'] = array(
'#title' => $this
->t('Font sizes'),
'#type' => 'textarea',
'#default_value' => $config['font_sizes'],
'#description' => $this
->t('Enter font sizes on new lines. Sizes must be added with the following syntax:<br><code>123px|Size label</code><br><code>123em|Size label</code><br><code>123%|Size label</code>'),
'#element_validate' => array(
array(
$this,
'validateFontSizeValue',
),
),
);
return $form;
}