Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-alexander committed Sep 14, 2021
1 parent e48adc4 commit 868f444
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,39 @@
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { useSelect, useDispatch } from '@wordpress/data';
import { createBlock, rawHandler } from '@wordpress/blocks';

/**
* Internal dependencies
*/
import Warning from '../warning';
import { store as blockEditorStore } from '../../store';

export default function BlockInvalidWarning( { blockTitle, icon, clientId } ) {
const selector = ( select ) => {
const { getBlock } = select( blockEditorStore );
const block = getBlock( clientId );
return {
block,
};
};

const { block } = useSelect( selector, [ clientId ] );

const { name, attributes, innerBlocks } = block;

const { replaceBlock } = useDispatch( blockEditorStore );

replaceBlock(
block.clientId,
createBlock( name, attributes, innerBlocks )
);

//rawHandler( {
// HTML: block.originalContent,
//} );

export default function BlockInvalidWarning( { blockTitle, icon } ) {
const accessibilityLabel = sprintf(
/* translators: accessibility text for blocks with invalid content. %d: localized block title */
__( '%s block. This block has invalid content' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class BlockListBlock extends Component {
<BlockInvalidWarning
blockTitle={ title }
icon={ icon }
clientId={ clientId }
/>
) }
<View
Expand Down

0 comments on commit 868f444

Please sign in to comment.