function CKEditor5::getGeneratedAllowedHtmlValue
Same name in other branches
- 9 core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php \Drupal\ckeditor5\Plugin\Editor\CKEditor5::getGeneratedAllowedHtmlValue()
- 11.x core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php \Drupal\ckeditor5\Plugin\Editor\CKEditor5::getGeneratedAllowedHtmlValue()
Value callback to set the CKEditor 5-generated "allowed_html" value.
Used to set the value of filter_html's "allowed_html" form item if the form has been validated and hence `ckeditor5_validated_pair` is available in form state. This allows setting a guaranteed to be valid value.
`ckeditor5_validated_pair` can be set from two places:
- When switching to CKEditor 5, this is populated by CKEditor5::buildConfigurationForm().
- When making filter or editor settings changes, it is populated by CKEditor5::validateConfigurationForm().
Parameters
array $element: An associative array containing the properties of the element.
mixed $input: The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
string The value to assign to the element.
File
-
core/
modules/ ckeditor5/ src/ Plugin/ Editor/ CKEditor5.php, line 582
Class
- CKEditor5
- Defines a CKEditor 5-based text editor for Drupal.
Namespace
Drupal\ckeditor5\Plugin\EditorCode
public static function getGeneratedAllowedHtmlValue(array &$element, $input, FormStateInterface $form_state) : string {
if ($form_state->isValidationComplete()) {
$validated_format = $form_state->get('ckeditor5_validated_pair')
->getFilterFormat();
$configuration = $validated_format->filters()
->get('filter_html')
->getConfiguration();
return $configuration['settings']['allowed_html'];
}
else {
if ($input !== FALSE) {
return $input;
}
return $element['#default_value'];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.