Skip to content

Commit

Permalink
Add Text Columns → Columns transform (#9364)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill authored and youknowriad committed Aug 27, 2018
1 parent 43e701a commit 349e892
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/block-library/src/text-columns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { get, times } from 'lodash';
/**
* WordPress dependencies
*/
import { createBlock } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import { PanelBody, RangeControl } from '@wordpress/components';
import { Fragment } from '@wordpress/element';
Expand Down Expand Up @@ -54,6 +55,32 @@ export const settings = {
},
},

transforms: {
to: [
{
type: 'block',
blocks: [ 'core/columns' ],
transform: ( { className, columns, content, width } ) => (
createBlock(
'core/columns',
{
align: ( 'wide' === width || 'full' === width ) ? width : undefined,
className,
columns,
},
content.map( ( { children } ) =>
createBlock(
'core/column',
{},
[ createBlock( 'core/paragraph', { content: children } ) ]
)
)
)
),
},
],
},

getEditWrapperProps( attributes ) {
const { width } = attributes;
if ( 'wide' === width || 'full' === width ) {
Expand Down

0 comments on commit 349e892

Please sign in to comment.