Skip to content

Instantly share code, notes, and snippets.

@phpbits
Created August 6, 2019 10:20
Show Gist options
  • Save phpbits/03b62378c0e596dd0eb4c35e72287a5d to your computer and use it in GitHub Desktop.
Save phpbits/03b62378c0e596dd0eb4c35e72287a5d to your computer and use it in GitHub Desktop.
/**
* WordPress dependencies
*/
const { __ } = wp.i18n;
const { registerBlockType } = wp.blocks;
const { InnerBlocks } = wp.blockEditor;
registerBlockType( 'custom-block/container', {
title: __( 'Custom Container' ),
description: __( 'Provide custom container.' ),
keywords: [
__( 'container' ),
__( 'wrapper' ),
__( 'section' ),
],
supports: {
align: [ 'wide', 'full' ],
anchor: true,
html: false,
},
category: 'common',
icon: 'editor-kitchensink',
attributes: {
content: {
type: 'string',
},
},
edit: ( props ) => {
const { className } = props;
return (
<div className={ className }>
<InnerBlocks renderAppender={ InnerBlocks.ButtonBlockAppender } />
</div>
);
},
save: ( props ) => {
const { className } = props;
return (
<div className={ className }>
<InnerBlocks.Content />
</div>
);
},
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment