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

Issue #3466381 by just_like_good_vibes: Wysiwyg field doesn't load text format on edit screen

parent d5149893
No related branches found
No related tags found
No related merge requests found
......@@ -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.
Please register or to comment