Skip to content

Commit

Permalink
Revert "Missing Block: Support extraction of inner blocks"
Browse files Browse the repository at this point in the history
This reverts commit 728f2f3.
  • Loading branch information
Tug committed Jul 9, 2019
1 parent 728f2f3 commit c65b3b5
Showing 1 changed file with 6 additions and 32 deletions.
38 changes: 6 additions & 32 deletions packages/block-library/src/missing/edit.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,30 @@
/**
* External dependencies
*/
import { get } from 'lodash';

/**
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { RawHTML } from '@wordpress/element';
import { Button } from '@wordpress/components';
import { getBlockType, createBlock, parse } from '@wordpress/blocks';
import { getBlockType, createBlock } from '@wordpress/blocks';
import { withDispatch } from '@wordpress/data';
import { Warning } from '@wordpress/block-editor';

function MissingBlockWarning( { attributes, convertToHTML, extractBlocks } ) {
function MissingBlockWarning( { attributes, convertToHTML } ) {
const { originalName, originalUndelimitedContent } = attributes;
const hasContent = !! originalUndelimitedContent;
const parseTree = parse( attributes.originalContent );
const hasInnerBlocks = get( parseTree, [ 0, 'innerBlocks' ], [] ).length;
const hasHTMLBlock = getBlockType( 'core/html' );

const actions = [];
let messageHTML;
if ( hasContent && hasHTMLBlock ) {
messageHTML = hasInnerBlocks ?
sprintf(
__( 'Your site doesn’t include support for the "%s" block. You can leave this block intact, convert its content to a Custom HTML block, extract any blocks it may contain, or remove it entirely.' ),
originalName
) :
sprintf(
__( 'Your site doesn’t include support for the "%s" block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely.' ),
originalName
);
messageHTML = sprintf(
__( 'Your site doesn’t include support for the "%s" block. You can leave this block intact, convert its content to a Custom HTML block, or remove it entirely.' ),
originalName
);
actions.push(
<Button key="convert" onClick={ convertToHTML } isLarge isPrimary>
{ __( 'Keep as HTML' ) }
</Button>
);
if ( hasInnerBlocks ) {
actions.push(
<Button key="extract" onClick={ extractBlocks } isLarge>
{ __( 'Keep inner blocks' ) }
</Button>
);
}
} else {
messageHTML = sprintf(
__( 'Your site doesn’t include support for the "%s" block. You can leave this block intact or remove it entirely.' ),
Expand All @@ -69,13 +50,6 @@ const MissingEdit = withDispatch( ( dispatch, { clientId, attributes } ) => {
content: attributes.originalUndelimitedContent,
} ) );
},
extractBlocks() {
replaceBlock( clientId, get(
parse( attributes.originalContent ),
[ 0, 'innerBlocks' ],
[]
) );
},
};
} )( MissingBlockWarning );

Expand Down

0 comments on commit c65b3b5

Please sign in to comment.