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

Add Text Columns → Columns transform #9364

Merged
merged 2 commits into from
Aug 27, 2018
Merged
Changes from 1 commit
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
32 changes: 30 additions & 2 deletions packages/block-library/src/columns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ const getColumnsTemplate = memoize( ( columns ) => {
return times( columns, () => [ 'core/column' ] );
} );

const supports = {
align: [ 'wide', 'full' ],
};

export const name = 'core/columns';

export const settings = {
Expand All @@ -62,8 +66,32 @@ export const settings = {

description: __( 'Add a block that displays content in multiple columns, then add whatever content blocks you’d like.' ),

supports: {
align: [ 'wide', 'full' ],
supports,

transforms: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move the declaration of this transform the the text-columns block instead (to transform) that way when/if we remove the block, we don't forget the transform.

from: [
{
type: 'block',
blocks: [ 'core/text-columns' ],
transform: ( { className, columns, content, width } ) => (
createBlock(
'core/columns',
{
align: supports.align.includes( width ) ? width : undefined,
className,
columns,
},
content.map( ( { children } ) =>
createBlock(
'core/column',
{},
[ createBlock( 'core/paragraph', { content: children } ) ]
)
)
)
),
},
],
},

deprecated: [
Expand Down