Skip to content
Snippets Groups Projects

Issue #3228334: Refactor HTMLRestrictionsUtilities to a HtmlRestrictions value object

Compare and
15 files
+ 1883
517
Compare changes
  • Side-by-side
  • Inline
Files
15
@@ -4,7 +4,7 @@
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;
@@ -43,7 +43,7 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form
// 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::fromString($form_value)->toCKEditor5ElementsArray();
$form_state->setValue('allowed_tags', $config_value);
}
}
@@ -75,11 +75,10 @@ public function getElementsSubset(): array {
* {@inheritdoc}
*/
public function getDynamicPluginConfig(array $static_plugin_config, EditorInterface $editor): array {
$allowed = HTMLRestrictionsUtilities::allowedElementsStringToHtmlSupportConfig(implode('', $this->configuration['allowed_tags']));
$restrictions = HTMLRestrictions::fromString(implode(' ', $this->configuration['allowed_tags']));
return [
'htmlSupport' => [
'allow' => $allowed,
'allow' => $restrictions->toGeneralHtmlSupportConfig(),
],
];
}
Loading