Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heading, List: Fix onMerge errors #3917

Merged
merged 3 commits into from
Dec 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions blocks/api/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
} ) );
}

Expand Down
1 change: 1 addition & 0 deletions blocks/editable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
11 changes: 7 additions & 4 deletions blocks/library/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: <p> { get( value, 'props.children' ) } </p> } ) ),
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: <p>{ children }</p> } ) ),
citation: ( values.length === 1 ? undefined : [ get( last( values ), 'props.children' ) ] ),
} );
},
},
Expand Down