diff --git a/extensions/blocks/videopress/deprecated/v1/index.js b/extensions/blocks/videopress/deprecated/v1/index.js index b9ead7eed2972..ed4f99685b291 100644 --- a/extensions/blocks/videopress/deprecated/v1/index.js +++ b/extensions/blocks/videopress/deprecated/v1/index.js @@ -44,4 +44,5 @@ export default { reusable: false, }, save, + isDeprecation: true, }; diff --git a/extensions/blocks/videopress/editor.js b/extensions/blocks/videopress/editor.js index c91e584c6a653..3b27431796d3e 100644 --- a/extensions/blocks/videopress/editor.js +++ b/extensions/blocks/videopress/editor.js @@ -16,10 +16,13 @@ import getJetpackExtensionAvailability from '../../shared/get-jetpack-extension- import deprecatedV1 from './deprecated/v1'; const addVideoPressSupport = ( settings, name ) => { - if ( 'core/video' !== name ) { + // Bail if this is not the video block or if the hook has been triggered by a deprecation. + if ( 'core/video' !== name || settings.isDeprecation ) { return settings; } + const { attributes, deprecated, edit, save, supports, transforms } = settings; + const { available, unavailableReason } = getJetpackExtensionAvailability( 'videopress' ); // We customize the video block even if VideoPress it not available so we can support videos that were uploaded to @@ -69,7 +72,7 @@ const addVideoPressSupport = ( settings, name ) => { }, transforms: { - ...settings.transforms, + ...transforms, from: [ { type: 'files', @@ -99,19 +102,22 @@ const addVideoPressSupport = ( settings, name ) => { }, supports: { - ...settings.supports, + ...supports, reusable: false, }, - edit: withVideoPressEdit( settings.edit ), + edit: withVideoPressEdit( edit ), - save: withVideoPressSave( settings.save ), + save: withVideoPressSave( save ), deprecated: [ + ...( deprecated || [] ), { - attributes: settings.attributes, - save: settings.save, + attributes, isEligible: attrs => ! attrs.guid, + save, + supports, + isDeprecation: true, }, deprecatedV1, ],