Extending the Story Block doesn’t work as expected
-
Hi,
I am trying to extend the Story Block in order to provide support for a Transcoding plugin, I want to save a custom value in an attribute created by the said plugin.
I am able to extend and add a new setting to the Inspector Control, however the attributes aren’t being added to AMP Story Block.
/** * Add background video quality attribute to block. * * @param {object} settings Current block settings. * @param {string} name Name of block. * * @returns {object} Modified block settings. */ const addBackgroundVideoQualityControlAttribute = ( settings, name ) => { if ( ! enableTranscoderSettingsOnBlocks.includes( name ) ) { return settings; } //check if object exists for old Gutenberg version compatibility if ( typeof settings.attributes !== 'undefined' ) { settings.attributes = Object.assign( settings.attributes, { rtBackgroundVideoQuality: { type: 'string', default: defaultVideoQuality, }, } ); } return settings; }; addFilter( 'blocks.registerBlockType', 'transcoder/ampStoryBackgroundVideoQuality', addBackgroundVideoQualityControlAttribute );
The above code checks block name from a constant of block on which the attribute has to be added.
Here is the current value of the constant.
// Enable Transcoder settings on the following blocks const enableTranscoderSettingsOnBlocks = [ 'amp/amp-story-page', 'core/video', ];
This is working as expected for the core block, however causing issue in case of the Story Block.
I believe this is a similar issue https://github.com/WordPress/gutenberg/issues/18709
Here is the full gist, which has current code used to achieve this https://gist.github.com/thrijith/8cff51c88151a08849faafccb7192d70
Changing hook priority for
enqueue_block_editor_assets
also doesn’t work.Is this an expected behaviour?
- The topic ‘Extending the Story Block doesn’t work as expected’ is closed to new replies.