class ListPlugin
Same name in other branches
- 9 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/ListPlugin.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\ListPlugin
- 10 core/modules/ckeditor5/src/Plugin/CKEditor5Plugin/ListPlugin.php \Drupal\ckeditor5\Plugin\CKEditor5Plugin\ListPlugin
CKEditor 5 List plugin.
@internal Plugin classes are internal.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\ckeditor5\Plugin\CKEditor5PluginDefault extends \Drupal\Core\Plugin\PluginBase implements \Drupal\ckeditor5\Plugin\CKEditor5PluginInterface
- class \Drupal\ckeditor5\Plugin\CKEditor5Plugin\ListPlugin extends \Drupal\ckeditor5\Plugin\CKEditor5PluginDefault implements \Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableInterface, \Drupal\ckeditor5\Plugin\CKEditor5PluginElementsSubsetInterface uses \Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableTrait
- class \Drupal\ckeditor5\Plugin\CKEditor5PluginDefault extends \Drupal\Core\Plugin\PluginBase implements \Drupal\ckeditor5\Plugin\CKEditor5PluginInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of ListPlugin
1 file declares its use of ListPlugin
- ListPluginTest.php in core/
modules/ ckeditor5/ tests/ src/ Unit/ ListPluginTest.php
1 string reference to 'ListPlugin'
- ckeditor5.ckeditor5.yml in core/
modules/ ckeditor5/ ckeditor5.ckeditor5.yml - core/modules/ckeditor5/ckeditor5.ckeditor5.yml
File
-
core/
modules/ ckeditor5/ src/ Plugin/ CKEditor5Plugin/ ListPlugin.php, line 20
Namespace
Drupal\ckeditor5\Plugin\CKEditor5PluginView source
class ListPlugin extends CKEditor5PluginDefault implements CKEditor5PluginConfigurableInterface, CKEditor5PluginElementsSubsetInterface {
use CKEditor5PluginConfigurableTrait;
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
'properties' => [
'reversed' => TRUE,
'startIndex' => TRUE,
],
'multiBlock' => TRUE,
];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['reversed'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow the user to reverse an ordered list'),
'#default_value' => $this->configuration['properties']['reversed'],
];
$form['startIndex'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow the user to specify the start index of an ordered list'),
'#default_value' => $this->configuration['properties']['startIndex'],
];
$form['multiBlock'] = [
'#type' => 'checkbox',
'#title' => $this->t('Allow the user to create paragraphs in list items (or other block elements)'),
'#default_value' => $this->configuration['multiBlock'],
];
return $form;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
$form_value = $form_state->getValue('reversed');
$form_state->setValue('reversed', (bool) $form_value);
$form_value = $form_state->getValue('startIndex');
$form_state->setValue('startIndex', (bool) $form_value);
$form_value = $form_state->getValue('multiBlock');
$form_state->setValue('multiBlock', (bool) $form_value);
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this->configuration['properties']['reversed'] = $form_state->getValue('reversed');
$this->configuration['properties']['startIndex'] = $form_state->getValue('startIndex');
$this->configuration['multiBlock'] = $form_state->getValue('multiBlock');
}
/**
* {@inheritdoc}
*/
public function getDynamicPluginConfig(array $static_plugin_config, EditorInterface $editor) : array {
$static_plugin_config['list']['properties'] = $this->getConfiguration()['properties'] + $static_plugin_config['list']['properties'];
$static_plugin_config['list']['multiBlock'] = $this->getConfiguration()['multiBlock'];
return $static_plugin_config;
}
/**
* {@inheritdoc}
*/
public function getElementsSubset() : array {
$subset = $this->getPluginDefinition()
->getElements();
$subset = array_diff($subset, [
'<ol reversed start>',
]);
$reversed_enabled = $this->getConfiguration()['properties']['reversed'];
$start_index_enabled = $this->getConfiguration()['properties']['startIndex'];
$subset[] = "<ol" . ($reversed_enabled ? ' reversed' : '') . ($start_index_enabled ? ' start' : '') . '>';
return $subset;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.