Skip to content
Snippets Groups Projects
Commit 2caae136 authored by Mikael Meulle's avatar Mikael Meulle
Browse files

Merge branch '3466381-2.0.0-beta1-wysiwyg-field' into '2.0.x'

Fixed WysiwygWidget with proper altering of text_format element

See merge request !177
parents d5149893 865d7e60
No related branches found
No related tags found
No related merge requests found
Pipeline #246739 passed
......@@ -40,6 +40,9 @@ class WysiwygWidget extends SourcePluginBase implements TrustedCallbackInterface
* Processed element
*/
public static function textFormat(array $element) : array {
if (!isset($element['#ui_patterns']) || !$element['#ui_patterns']) {
return $element;
}
if (isset($element['format']['format']['#access']) &&
!$element['format']['format']['#access']) {
// See code at Drupal\filter\Element\TextFormat::processTextFormat()
......@@ -87,9 +90,7 @@ class WysiwygWidget extends SourcePluginBase implements TrustedCallbackInterface
$value = $this->getSetting('value');
$element = [
'#type' => 'text_format',
'#pre_render' => [
[static::class, 'textFormat'],
],
'#ui_patterns' => TRUE,
];
if (is_array($value) && array_key_exists("value", $value)) {
$element['#default_value'] = $value['value'];
......
......@@ -7,6 +7,8 @@
declare(strict_types=1);
use Drupal\ui_patterns\Plugin\UiPatterns\Source\WysiwygWidget;
/**
* Implements hook_element_info_alter().
*/
......@@ -15,6 +17,9 @@ function ui_patterns_element_info_alter(array &$types): void {
array_unshift($types['component']['#pre_render'], 'ui_patterns.component_element_alter:alter');
array_unshift($types['component']['#pre_render'], 'ui_patterns.component_element_builder:build');
}
if (isset($types['text_format'])) {
$types['text_format']['#pre_render'][] = [WysiwygWidget::class, 'textFormat'];
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment