In order to support, Jetpack's Publicize plugin from the pre-publish sidebar, I am looking into how to attach meta keys to a publishing post. In my specific case, Publicize needs to set the title for a social post and define the list of connections that should be shared to. The classic editor does this in the form data header:

The current extensibility approach for editor plugins is to use registerPlugin to register a Fill component for some some slot in the UI. I would propose extending registerPlugin to allow the definition of an attributes field, just like registerBlockType. This could look something like the following:
registerPlugin( 'plugin-name', {
render: Component,
attributes: {
author: {
type: 'string',
source: 'meta',
meta: 'author'
},
},
} );
With this approach, the plugin could potentially set its associated attributes with setAttribute (as blocks do).
CC @aduth , @gziolo
I think this is already possible without another specific API.
you can do something like this to retrieve the attribute: const metaAttributes = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'meta' )
and do something like this to update them: wp.data.dispatch( 'core/editor' ).editPost( { meta: newMetaAttributes } )
you can use withSelect and withDispatch Higher Order Components to provide these utilities as props to your component.
I agree with @youknowriad . To me, this seems like something which should be easier than it is now, but via the data module, not a dedicated API.
Oh great! I hadn't found that yet. Would it be good to document this somewhere (assuming it's not already somewhere that I overlooked)? Maybe in https://github.com/WordPress/gutenberg/blob/master/docs/attributes.md ?
Yes, it's not documented properly yet because we'd like to automate the selectors and actions documentation. The data module in itself is documented here though https://github.com/WordPress/gutenberg/tree/master/data
Thanks!
Most helpful comment
I think this is already possible without another specific API.
you can do something like this to retrieve the attribute:
const metaAttributes = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'meta' )and do something like this to update them:
wp.data.dispatch( 'core/editor' ).editPost( { meta: newMetaAttributes } )you can use
withSelectandwithDispatchHigher Order Components to provide these utilities as props to your component.