Skip to content
Snippets Groups Projects

Fixed WysiwygWidget with proper altering of text_format element

2 files
+ 9
3
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -40,6 +40,9 @@ class WysiwygWidget extends SourcePluginBase implements TrustedCallbackInterface
@@ -40,6 +40,9 @@ class WysiwygWidget extends SourcePluginBase implements TrustedCallbackInterface
* Processed element
* Processed element
*/
*/
public static function textFormat(array $element) : array {
public static function textFormat(array $element) : array {
 
if (!isset($element['#ui_patterns']) || !$element['#ui_patterns']) {
 
return $element;
 
}
if (isset($element['format']['format']['#access']) &&
if (isset($element['format']['format']['#access']) &&
!$element['format']['format']['#access']) {
!$element['format']['format']['#access']) {
// See code at Drupal\filter\Element\TextFormat::processTextFormat()
// See code at Drupal\filter\Element\TextFormat::processTextFormat()
@@ -87,9 +90,7 @@ class WysiwygWidget extends SourcePluginBase implements TrustedCallbackInterface
@@ -87,9 +90,7 @@ class WysiwygWidget extends SourcePluginBase implements TrustedCallbackInterface
$value = $this->getSetting('value');
$value = $this->getSetting('value');
$element = [
$element = [
'#type' => 'text_format',
'#type' => 'text_format',
'#pre_render' => [
'#ui_patterns' => TRUE,
[static::class, 'textFormat'],
],
];
];
if (is_array($value) && array_key_exists("value", $value)) {
if (is_array($value) && array_key_exists("value", $value)) {
$element['#default_value'] = $value['value'];
$element['#default_value'] = $value['value'];
Loading