Skip to content
Snippets Groups Projects

Issue #3228334: [PP-1] Refactor HTMLRestrictionsUtilities to a HtmlRestrictions value object

Files
10
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Drupal\ckeditor5\Plugin\CKEditor5Plugin;
use Drupal\ckeditor5\HTMLRestrictionsUtilities;
use Drupal\ckeditor5\HTMLRestrictions;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableTrait;
use Drupal\ckeditor5\Plugin\CKEditor5PluginDefault;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableInterface;
@@ -40,7 +40,7 @@ class SourceEditing extends CKEditor5PluginDefault implements CKEditor5PluginCon
// Match the config schema structure at ckeditor5.plugin.ckeditor5_heading.
$form_value = $form_state->getValue('allowed_tags');
if (!is_array($form_value)) {
$config_value = HTMLRestrictionsUtilities::allowedElementsStringToPluginElementsArray($form_value);
$config_value = HTMLRestrictions::parse($form_value)->toCKEditor5ElementsArray();
$form_state->setValue('allowed_tags', $config_value);
}
}
@@ -72,11 +72,9 @@ class SourceEditing extends CKEditor5PluginDefault implements CKEditor5PluginCon
* {@inheritdoc}
*/
public function getDynamicPluginConfig(array $static_plugin_config, EditorInterface $editor): array {
$allowed = HTMLRestrictionsUtilities::allowedElementsStringToHtmlSupportConfig(implode('', $this->configuration['allowed_tags']));
return [
'htmlSupport' => [
'allow' => $allowed,
'allow' => HTMLRestrictions::parse($this->configuration['allowed_tags'])->toGeneralHtmlSupportConfig(),
],
];
}
Loading