From 4214a5fa8748d85cbf15d8a199a77139938b8cb4 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Fri, 1 Dec 2023 17:53:08 +0100 Subject: [PATCH] Add native workaround for HTML block in `htmlToBlocks` --- .../blocks/src/api/raw-handling/html-to-blocks.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/blocks/src/api/raw-handling/html-to-blocks.js b/packages/blocks/src/api/raw-handling/html-to-blocks.js index 18630a9abdce45..1ee2bdc263126f 100644 --- a/packages/blocks/src/api/raw-handling/html-to-blocks.js +++ b/packages/blocks/src/api/raw-handling/html-to-blocks.js @@ -1,7 +1,13 @@ +/** + * WordPress dependencies + */ +import { Platform } from '@wordpress/element'; + /** * Internal dependencies */ import { createBlock, findTransform } from '../factory'; +import parse from '../parser'; import { getBlockAttributes } from '../parser/get-block-attributes'; import { getRawTransforms } from './get-raw-transforms'; @@ -28,6 +34,13 @@ export function htmlToBlocks( html, handler ) { ); if ( ! rawTransform ) { + // Until the HTML block is supported in the native version, we'll parse it + // instead of creating the block to generate it as an unsupported block. + if ( Platform.isNative ) { + return parse( + `${ node.outerHTML }` + ); + } return createBlock( // Should not be hardcoded. 'core/html',