Skip to content

Commit

Permalink
Handle block (un)wrapping in a separate PR
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Apr 11, 2018
1 parent bf8c171 commit 8929b5f
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 120 deletions.
29 changes: 1 addition & 28 deletions blocks/library/list/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { find, compact, get, initial, last, isEmpty } from 'lodash';
import { find, compact, get, isEmpty } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -61,21 +61,6 @@ export const settings = {
} );
},
},
{
type: 'block',
blocks: [ 'core/quote' ],
transform: ( { value, citation } ) => {
const items = value.map( p => get( p, 'children.props.children' ) );
if ( ! isEmpty( citation ) ) {
items.push( citation );
}
const hasItems = ! items.every( isEmpty );
return createBlock( 'core/list', {
nodeName: 'UL',
values: hasItems ? items.map( ( content, index ) => <li key={ index }>{ content }</li> ) : [],
} );
},
},
{
type: 'raw',
isMatch: ( node ) => node.nodeName === 'OL' || node.nodeName === 'UL',
Expand Down Expand Up @@ -111,18 +96,6 @@ export const settings = {
content: [ content ],
} ) ),
},
{
type: 'block',
blocks: [ 'core/quote' ],
transform: ( { values } ) => {
return createBlock( 'core/quote', {
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
12 changes: 0 additions & 12 deletions blocks/library/pullquote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,6 @@ export const settings = {

attributes: blockAttributes,

transforms: {
to: [
{
type: 'unwrap',
transform: ( { citation }, innerBlocks ) => [
...innerBlocks,
createBlock( 'core/paragraph', { content: citation } ),
],
},
],
},

getEditWrapperProps( attributes ) {
const { align } = attributes;
if ( 'left' === align || 'right' === align || 'wide' === align || 'full' === align ) {
Expand Down
9 changes: 0 additions & 9 deletions blocks/library/quote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ export const settings = {
},
},
],
to: [
{
type: 'unwrap',
transform: ( { citation }, innerBlocks ) => [
...innerBlocks,
createBlock( 'core/paragraph', { content: citation } ),
],
},
],
},

edit: withState( {
Expand Down
69 changes: 0 additions & 69 deletions editor/components/block-settings-menu/block-unwrap.js

This file was deleted.

2 changes: 0 additions & 2 deletions editor/components/block-settings-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import BlockModeToggle from './block-mode-toggle';
import BlockRemoveButton from './block-remove-button';
import BlockDuplicateButton from './block-duplicate-button';
import BlockTransformations from './block-transformations';
import BlockUnwrap from './block-unwrap';
import SharedBlockSettings from './shared-block-settings';
import UnknownConverter from './unknown-converter';
import { selectBlock } from '../../store/actions';
Expand Down Expand Up @@ -67,7 +66,6 @@ function BlockSettingsMenu( {
<BlockRemoveButton key="remove" uids={ uids } role="menuitem" />,
<BlockDuplicateButton key="duplicate" uids={ uids } rootUID={ rootUID } role="menuitem" />,
count === 1 && <SharedBlockSettings key="shared-block" uid={ uids[ 0 ] } onToggle={ onClose } itemsRole="menuitem" />,
<BlockUnwrap key="block-unwrap" uids={ uids } onClick={ onClose } role="menuitem" />,
<BlockTransformations key="transformations" uids={ uids } onClick={ onClose } itemsRole="menuitem" />,
] } ) }
</NavigableMenu>
Expand Down

0 comments on commit 8929b5f

Please sign in to comment.