public function BsGrid::settingsForm in CKEditor Bootstrap Grid 2.0.x
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/ BsGrid.php, line 81
Class
- BsGrid
- Defines the "bs_grid" plugin.
Namespace
Drupal\ckeditor_bs_grid\Plugin\CKEditorPluginCode
public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
$settings = $editor
->getSettings();
$config = $settings['plugins']['bs_grid'] ?? [];
$form['use_cdn'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Use BS CDN'),
'#description' => $this
->t('If your theme utilizing CKEditor does not include bootstrap grid classes, or pass them via "ckeditor_stylesheets" then you can include it here. This will ONLY include it for ckeditor.'),
'#default_value' => $config['use_cdn'] ?? TRUE,
];
$form['cdn_url'] = [
'#type' => 'textfield',
'#title' => $this
->t('CDN URL'),
'#description' => $this
->t('The URL to your Bootstrap CDN, default is for grid-only.'),
'#default_value' => $config['cdn_url'] ?? 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.2/css/bootstrap-grid.min.css',
];
$form['available_columns'] = [
'#title' => $this
->t('Allowed Columns'),
'#type' => 'checkboxes',
'#options' => array_combine($r = range(1, 12), $r),
'#default_value' => $config['available_columns'] ?? [],
'#prefix' => '<div class="container-inline">',
'#suffix' => '</div>',
'#required' => TRUE,
];
$bs_breakpoints = $this->configFactory
->get('ckeditor_bs_grid.settings')
->get('breakpoints');
$breakpoint_options = [];
foreach ($bs_breakpoints as $class => $breakpoint) {
$breakpoint_options[$class] = $breakpoint['label'];
}
$form['available_breakpoints'] = [
'#title' => $this
->t('Allowed Breakpoints'),
'#type' => 'checkboxes',
'#options' => $breakpoint_options,
'#default_value' => $config['available_breakpoints'] ?? [],
'#required' => TRUE,
];
return $form;
}