Skip to content

Commit

Permalink
Block warning: add convert to classic option
Browse files Browse the repository at this point in the history
Makes use of the new ellipsis menu to present the sa,e convert to blocks option along with a convert to classic block
  • Loading branch information
johngodley committed Aug 13, 2018
1 parent 17aea52 commit 79f5549
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { withDispatch } from '@wordpress/data';
*/
import Warning from '../warning';

function BlockInvalidWarning( { convertToHTML, convertToBlocks } ) {
function BlockInvalidWarning( { convertToHTML, convertToBlocks, convertToClassic } ) {
const hasHTMLBlock = !! getBlockType( 'core/html' );

return (
Expand All @@ -30,6 +30,10 @@ function BlockInvalidWarning( { convertToHTML, convertToBlocks } ) {
</Button>
),
] }
hiddenActions={ [
{ title: __( 'Convert to Blocks' ), onClick: convertToBlocks },
{ title: __( 'Convert to Classic Block' ), onClick: convertToClassic },
] }
>
{ __( 'This block has been modified externally.' ) }
</Warning>
Expand All @@ -39,6 +43,11 @@ function BlockInvalidWarning( { convertToHTML, convertToBlocks } ) {
export default withDispatch( ( dispatch, { block } ) => {
const { replaceBlock } = dispatch( 'core/editor' );
return {
convertToClassic() {
replaceBlock( block.uid, createBlock( 'core/freeform', {
content: block.originalContent,
} ) );
},
convertToHTML() {
replaceBlock( block.clientId, createBlock( 'core/html', {
content: block.originalContent,
Expand Down

0 comments on commit 79f5549

Please sign in to comment.