Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
( function() {
var registerBlockType = wp.blocks.registerBlockType;
var el = wp.element.createElement;
var InnerBlocks = wp.editor.InnerBlocks;
registerBlockType( 'test/parent', {
title: 'Test Parent',
icon: 'cart',
category: 'common',
edit: function() {
return el( 'div', { style: { outline: '1px solid gray', padding: 5 } },
el(
InnerBlocks,
{
template: [
[ 'test/child' ],
],
templateLock: false,
}
)
);
},
save: function() {
return el( 'div', { style: { outline: '1px solid gray', padding: 5 } },
el( InnerBlocks.Content, {} )
);
},
} );
registerBlockType( 'test/child', {
title: 'Test Child',
icon: 'cart',
category: 'common',
parent: [ 'test/parent' ],
supports: {
inserter: true,
},
edit: function() {
return 'Child';
},
save: function() {
return 'Child';
},
} );
} )();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.