Fields middleware for Gutenberg

At the moment, registering fields for your Gutenberg block requires a bunch of repetitive code to produce similar UI.

For instance, to produce a text control, you need to do something like this:

el( wp.blocks.InspectorControls.TextControl, {
	value: url,
	onChange: function( newVal ) {
			url: newVal
	placeholder: __( 'Enter a GitHub Gist URL' ),
} );

See? A lot of boilerplate that you need to repeat for each text control.

For the simple UI, this boilerplate shouldn't be necessary. I'd much rather define a field type when registering the attribute:

attributes: {
	url: {
		type: 'string',
		field: 'text',

It sure would be awesome if this existed as middleware!

One Reply to “Fields middleware for Gutenberg”

Leave a Reply

Your email address will not be published. Required fields are marked *