Skip to content

Commit

Permalink
Add native workaround for HTML block in htmlToBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
fluiddot committed Dec 1, 2023
1 parent 37bca49 commit 4214a5f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/blocks/src/api/raw-handling/html-to-blocks.js
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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(
`<!-- wp:html -->${ node.outerHTML }<!-- /wp:html -->`
);
}
return createBlock(
// Should not be hardcoded.
'core/html',
Expand Down

0 comments on commit 4214a5f

Please sign in to comment.