From 200886726d771e6ab0e777c858f1f434ca878b79 Mon Sep 17 00:00:00 2001 From: John Godley Date: Wed, 11 Jul 2018 13:58:52 +0100 Subject: [PATCH] Block warning: add convert to classic option Makes use of the new ellipsis menu to present the sa,e convert to blocks option along with a convert to classic block --- editor/components/block-list/block-invalid-warning.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/editor/components/block-list/block-invalid-warning.js b/editor/components/block-list/block-invalid-warning.js index d244fc2f27fe6..b42e0a896e96c 100644 --- a/editor/components/block-list/block-invalid-warning.js +++ b/editor/components/block-list/block-invalid-warning.js @@ -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 ( @@ -30,6 +30,10 @@ function BlockInvalidWarning( { convertToHTML, convertToBlocks } ) { ), ] } + hiddenActions={ [ + { title: __( 'Convert to Blocks' ), onClick: convertToBlocks }, + { title: __( 'Convert to Classic Block' ), onClick: convertToClassic }, + ] } > { __( 'This block has been modified externally.' ) } @@ -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,