From d664bf9daf3b6b331fa8e53e652433b480fc89d9 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Thu, 19 Dec 2024 16:15:37 +0000 Subject: [PATCH] Ensure `text` nodes are wrapped in `paragraph` nodes --- src/Transformers/BardTransformer.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Transformers/BardTransformer.php b/src/Transformers/BardTransformer.php index a57e002..bb11e2a 100644 --- a/src/Transformers/BardTransformer.php +++ b/src/Transformers/BardTransformer.php @@ -28,6 +28,13 @@ public function transform(string $value): array return collect($value) ->map(function (array $node): ?array { + if ($node['type'] === 'text') { + return [ + 'type' => 'paragraph', + 'content' => [$node], + ]; + } + if ($node['type'] === 'image' && $this->field->get('container') && isset($this->config['assets_base_url'])) { $assetContainer = AssetContainer::find($this->field->get('container'));