From 3b08d9d39375093e7a66a23f4189ebf52914d8b3 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Tue, 6 Jul 2021 19:31:25 +0200 Subject: [PATCH 1/3] Include missing attributes in upgraded embed block --- packages/block-library/src/embed/util.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/embed/util.js b/packages/block-library/src/embed/util.js index 49e98b015ba9e0..2acd1e834304de 100644 --- a/packages/block-library/src/embed/util.js +++ b/packages/block-library/src/embed/util.js @@ -95,7 +95,17 @@ export const createUpgradedEmbedBlock = ( props, attributesFromPreview = {} ) => { - const { preview, attributes: { url, providerNameSlug, type } = {} } = props; + const { + preview, + attributes: { + align, + allowResponsive, + caption, + url, + providerNameSlug, + type, + } = {}, + } = props; if ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) return; @@ -114,6 +124,9 @@ export const createUpgradedEmbedBlock = ( ! providerNameSlug ); if ( shouldCreateNewBlock ) { return createBlock( DEFAULT_EMBED_BLOCK, { + align, + allowResponsive, + caption, url, ...matchedBlock.attributes, } ); From 3709b6657b7977b37047aacdbb5cb400ac4be83f Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Wed, 7 Jul 2021 15:48:37 +0200 Subject: [PATCH 2/3] Update block-library changelog --- packages/block-library/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/block-library/CHANGELOG.md b/packages/block-library/CHANGELOG.md index 62ed002f5d028e..21549ecbb89369 100644 --- a/packages/block-library/CHANGELOG.md +++ b/packages/block-library/CHANGELOG.md @@ -7,6 +7,10 @@ - Removes the `core/legacy-widget` block. This is now in `@wordpress/widgets` via `registerLegacyWidgetBlock()`. +## Bug Fixes + +- Include missing attributes when upgrading embed block ([#33235](https://github.com/WordPress/gutenberg/pull/33235)) + ## 3.2.0 (2021-05-24) ### New Features From f9c347f369761c7b084e95dc5a18786f09a0bce4 Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Thu, 8 Jul 2021 11:13:48 +0200 Subject: [PATCH 3/3] Use rest of attributes when upgrading embed block --- packages/block-library/src/embed/util.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/packages/block-library/src/embed/util.js b/packages/block-library/src/embed/util.js index 2acd1e834304de..960e294856f8b3 100644 --- a/packages/block-library/src/embed/util.js +++ b/packages/block-library/src/embed/util.js @@ -95,17 +95,8 @@ export const createUpgradedEmbedBlock = ( props, attributesFromPreview = {} ) => { - const { - preview, - attributes: { - align, - allowResponsive, - caption, - url, - providerNameSlug, - type, - } = {}, - } = props; + const { preview, attributes = {} } = props; + const { url, providerNameSlug, type, ...restAttributes } = attributes; if ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) return; @@ -124,10 +115,8 @@ export const createUpgradedEmbedBlock = ( ! providerNameSlug ); if ( shouldCreateNewBlock ) { return createBlock( DEFAULT_EMBED_BLOCK, { - align, - allowResponsive, - caption, url, + ...restAttributes, ...matchedBlock.attributes, } ); }