From 73f8dc758f49c9660199a63814e26be3c21447e5 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Mon, 11 Dec 2017 15:17:25 +0000 Subject: [PATCH 1/3] Editable: Stop key propagation when merging blocks --- blocks/editable/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/blocks/editable/index.js b/blocks/editable/index.js index b2818952f70014..10de33f38900e7 100644 --- a/blocks/editable/index.js +++ b/blocks/editable/index.js @@ -558,6 +558,7 @@ export default class Editable extends Component { if ( event.shiftKey || ! this.props.onSplit ) { this.editor.execCommand( 'InsertLineBreak', false, event ); } else { + event.stopImmediatePropagation(); this.splitContent(); } } From 4968cbc7a3c3c3f11c08bef13e9e96dff877fe53 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Mon, 11 Dec 2017 15:18:51 +0000 Subject: [PATCH 2/3] core/list: Fix transforms to Paragraph & Quote --- blocks/library/list/index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/blocks/library/list/index.js b/blocks/library/list/index.js index 724a43cf6d29e5..b136253422fe1a 100644 --- a/blocks/library/list/index.js +++ b/blocks/library/list/index.js @@ -154,16 +154,19 @@ registerBlockType( 'core/list', { blocks: [ 'core/paragraph' ], transform: ( { values } ) => compact( values.map( ( value ) => get( value, 'props.children', null ) ) ) - .map( ( content ) => createBlock( 'core/paragraph', { content } ) ), + .map( ( content ) => createBlock( 'core/paragraph', { + content: [ content ], + } ) ), }, { type: 'block', blocks: [ 'core/quote' ], transform: ( { values } ) => { return createBlock( 'core/quote', { - value: ( values.length === 1 ? values : initial( values ) ) - .map( ( value ) => ( { children:

{ get( value, 'props.children' ) }

} ) ), - citation: ( values.length === 1 ? undefined : get( last( values ), 'props.children' ) ), + value: compact( ( values.length === 1 ? values : initial( values ) ) + .map( ( value ) => get( value, 'props.children', null ) ) ) + .map( ( children ) => ( { children:

{ children }

} ) ), + citation: ( values.length === 1 ? undefined : [ get( last( values ), 'props.children' ) ] ), } ); }, }, From 7e68bc4688a51491765dfa346463274ff6b7ad74 Mon Sep 17 00:00:00 2001 From: Miguel Fonseca Date: Mon, 11 Dec 2017 15:19:14 +0000 Subject: [PATCH 3/3] Fix previous typos --- blocks/api/factory.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blocks/api/factory.js b/blocks/api/factory.js index 121b155e122fd6..21d8c7791657bf 100644 --- a/blocks/api/factory.js +++ b/blocks/api/factory.js @@ -67,8 +67,8 @@ export function createBlock( name, blockAttributes = {} ) { export function switchToBlockType( blocks, name ) { const blocksArray = castArray( blocks ); const isMultiBlock = blocksArray.length > 1; - const fistBlock = blocksArray[ 0 ]; - const sourceName = fistBlock.name; + const firstBlock = blocksArray[ 0 ]; + const sourceName = firstBlock.name; if ( isMultiBlock && ! every( blocksArray, ( block ) => ( block.name === sourceName ) ) ) { return null; @@ -99,7 +99,7 @@ export function switchToBlockType( blocks, name ) { if ( transformation.isMultiBlock ) { transformationResults = transformation.transform( blocksArray.map( ( currentBlock ) => currentBlock.attributes ) ); } else { - transformationResults = transformation.transform( fistBlock.attributes ); + transformationResults = transformation.transform( firstBlock.attributes ); } // Ensure that the transformation function returned an object or an array @@ -130,7 +130,7 @@ export function switchToBlockType( blocks, name ) { ...result, // The first transformed block whose type matches the "destination" // type gets to keep the existing UID of the first block. - uid: index === firstSwitchedBlock ? fistBlock.uid : result.uid, + uid: index === firstSwitchedBlock ? firstBlock.uid : result.uid, } ) ); }