Created
August 24, 2018 22:19
-
-
Save jorgefilipecosta/7dbcf8ce79c57acc6eb2c64f0088f480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( 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: false, | |
}, | |
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