Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply default attributes on block migration #53120

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
*/
import { DEPRECATED_ENTRY_KEYS } from '../constants';
import { validateBlock } from '../validation';
import { getBlockAttributes } from './get-block-attributes';
import {
applyDefaultAttributes,
getBlockAttributes,
} from './get-block-attributes';
import { applyBuiltInValidationFixes } from './apply-built-in-validation-fixes';
import { omit } from '../utils';

Expand Down Expand Up @@ -113,7 +116,7 @@ export function applyBlockDeprecatedVersions( block, rawBlock, blockType ) {

block = {
...block,
attributes: migratedAttributes,
attributes: applyDefaultAttributes( blockType, migratedAttributes ),
innerBlocks: migratedInnerBlocks,
isValid: true,
validationIssues: [],
Expand Down
25 changes: 25 additions & 0 deletions packages/blocks/src/api/parser/get-block-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,28 @@ export function getBlockAttributes(
attributes
);
}

/**
* Applies default attributes from a block type to a set of attributes.
*
* @param {string|Object} blockTypeOrName Block type or name.
* @param {?Object} attributes Known block attributes (from delimiters).
*
* @return {Object} Block attributes with defaults applied.
*/
export function applyDefaultAttributes( blockTypeOrName, attributes = {} ) {
const blockType = normalizeBlockType( blockTypeOrName );

const blockAttributes = Object.fromEntries(
Object.entries( blockType.attributes ?? {} ).map(
( [ key, schema ] ) => [
key,
attributes[ key ] === undefined
? schema.default
: attributes[ key ],
]
)
);

return blockAttributes;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels like some kind of withDefaultsForMissingAttributes function.

also I think that it could make sense to move to a more imperative approach in this function, both for efficiency sake (no need to allocate the extra maps/arrays or break shallow-equality for attributes with all the required values) and from a clarity standpoint, to highlight the fill-if-missing-logic

export function withDefaultsForMissingAttributes( blockTypeOrName, attributes = {} ) {
	const blockType = normalizeBlockType( blockTypeOrName );
	if ( ! blockType.attributes ) {
		return attributes;
	}

	let allAttributes = null;

	for ( const key in blockType.attributes ) {
		if ( undefined !== attributes[ key ] ) {
			continue;
		}

		if ( null === allAttributes ) {
			allAttributes = { ...attributes };
		}

		allAttributes[ key ] = blockType.attributes[ key ].default;
	}

	// Only return a new object if default values were supplied.
	return null !== allAttributes
		? allAttributes
		: attributes;
}

Copy link
Contributor Author

@ajlende ajlende Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also I think that it could make sense to move to a more imperative approach in this function, both for efficiency sake (no need to allocate the extra maps/arrays or break shallow-equality for attributes with all the required values) and from a clarity standpoint, to highlight the fill-if-missing-logic

Yeah, it was just a quick copy of getBlockAttributes that didn't try to source values from the block content. Looks like everywhere that used to use _.mapValues uses the Object.entries style since #50285. It's easy enough to change here. getBlockAttributes should also probably be changed for better performance at some point too.

Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ describe( 'applyBlockDeprecatedVersions', () => {
} );
const blockType = registerBlockType( 'core/test-block', {
...defaultBlockSettings,
attributes: {
newFruit: {
type: 'string',
source: 'text',
selector: 'div',
},
},
save: ( props ) => <div>{ props.attributes.fruit }</div>,
deprecated: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"isValid": true,
"attributes": {
"tagName": "div",
"legacy": false,
"className": "wp-block-comments-query-loop comments-post-extra",
"textColor": "luminous-vivid-orange"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
"isValid": true,
"attributes": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",
"useFeaturedImage": false,
"id": 34,
"alt": "",
"hasParallax": false,
"isRepeated": false,
"dimRatio": 50,
"backgroundType": "image",
"isDark": true,
"tagName": "div"
},
"innerBlocks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- wp:cover {"url":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==","id":34,"dimRatio":50} -->
<div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-34" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-34" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size"><strong>Cover Image</strong></p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
"isValid": true,
"attributes": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",
"useFeaturedImage": false,
"id": 34,
"alt": "",
"hasParallax": false,
"isRepeated": false,
"dimRatio": 50,
"backgroundType": "image",
"isDark": true,
"tagName": "div"
},
"innerBlocks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- wp:cover {"url":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==","id":34,"dimRatio":50} -->
<div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-34" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-34" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size"><strong>Cover Block</strong></p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
"isValid": true,
"attributes": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",
"useFeaturedImage": false,
"id": 35,
"alt": "",
"hasParallax": false,
"isRepeated": false,
"dimRatio": 50,
"backgroundType": "image",
"isDark": true,
"tagName": "div"
},
"innerBlocks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- wp:cover {"url":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==","id":35,"dimRatio":50} -->
<div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-35" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-35" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size"><strong>Cover Block</strong></p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
"isValid": true,
"attributes": {
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",
"useFeaturedImage": false,
"id": 35,
"alt": "",
"hasParallax": false,
"isRepeated": false,
"dimRatio": 50,
"backgroundType": "image",
"focalPoint": {
"x": "0.07",
"y": "0.07"
},
"isDark": true,
"tagName": "div"
},
"innerBlocks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- wp:cover {"url":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==","id":35,"dimRatio":50,"focalPoint":{"x":"0.07","y":"0.07"}} -->
<div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-35" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==" style="object-position:7% 7%" data-object-fit="cover" data-object-position="7% 7%"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-35" alt="" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==" style="object-position:7% 7%" data-object-fit="cover" data-object-position="7% 7%"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size"><strong>Cover Block</strong></p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
"isValid": true,
"attributes": {
"url": "data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=",
"useFeaturedImage": false,
"alt": "",
"hasParallax": false,
"isRepeated": false,
"dimRatio": 50,
"backgroundType": "image",
"gradient": "midnight",
"isDark": true,
"tagName": "div"
},
"innerBlocks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- wp:cover {"url":"data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=","dimRatio":50,"gradient":"midnight"} -->
<div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-background-dim wp-block-cover__gradient-background has-background-gradient has-midnight-gradient-background"></span><img class="wp-block-cover__image-background" src="data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim wp-block-cover__gradient-background has-background-gradient has-midnight-gradient-background"></span><img class="wp-block-cover__image-background" alt="" src="data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size">Cover</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->
20 changes: 14 additions & 6 deletions test/integration/fixtures/blocks/core__cover__deprecated-6.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
"isValid": true,
"attributes": {
"url": "data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=",
"useFeaturedImage": false,
"alt": "",
"hasParallax": false,
"isRepeated": false,
"dimRatio": 40,
"backgroundType": "image",
"isRepeated": false,
"isDark": true,
"tagName": "div"
},
"innerBlocks": [
Expand All @@ -30,19 +33,22 @@
"isValid": true,
"attributes": {
"url": "https://example.com/some-background-image.png",
"useFeaturedImage": false,
"id": 1933,
"alt": "",
"hasParallax": false,
"isRepeated": false,
"dimRatio": 0,
"backgroundType": "image",
"focalPoint": {
"x": "0.50",
"y": "0.40"
},
"isRepeated": false,
"minHeight": 48,
"minHeightUnit": "vw",
"align": "full",
"tagName": "div"
"isDark": true,
"tagName": "div",
"align": "full"
},
"innerBlocks": [
{
Expand All @@ -61,13 +67,15 @@
"isValid": true,
"attributes": {
"url": "http://localhost:8888/wp-content/uploads/2021/02/percy.jpg",
"useFeaturedImage": false,
"id": 134,
"alt": "",
"hasParallax": false,
"isRepeated": false,
"dimRatio": 50,
"backgroundType": "image",
"isRepeated": false,
"contentPosition": "bottom right",
"alt": "",
"isDark": true,
"tagName": "div"
},
"innerBlocks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<!-- wp:cover {"url":"data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=","dimRatio":40} -->
<div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-40 has-background-dim"></span><img class="wp-block-cover__image-background" src="data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-40 has-background-dim"></span><img class="wp-block-cover__image-background" alt="" src="data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size">
Guten Berg!
</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->

<!-- wp:cover {"url":"https://example.com/some-background-image.png","id":1933,"dimRatio":0,"focalPoint":{"x":"0.50","y":"0.40"},"minHeight":48,"minHeightUnit":"vw","align":"full"} -->
<div class="wp-block-cover alignfull is-light" style="min-height:48vw"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-0 has-background-dim"></span><img class="wp-block-cover__image-background wp-image-1933" src="https://example.com/some-background-image.png" style="object-position:50% 40%" data-object-fit="cover" data-object-position="50% 40%"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph -->
<div class="wp-block-cover alignfull" style="min-height:48vw"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-0 has-background-dim"></span><img class="wp-block-cover__image-background wp-image-1933" alt="" src="https://example.com/some-background-image.png" style="object-position:50% 40%" data-object-fit="cover" data-object-position="50% 40%"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->

<!-- wp:cover {"url":"http://localhost:8888/wp-content/uploads/2021/02/percy.jpg","id":134,"dimRatio":50,"contentPosition":"bottom right"} -->
<div class="wp-block-cover is-light has-custom-content-position is-position-bottom-right"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-134" alt="" src="http://localhost:8888/wp-content/uploads/2021/02/percy.jpg" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<div class="wp-block-cover has-custom-content-position is-position-bottom-right"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-134" alt="" src="http://localhost:8888/wp-content/uploads/2021/02/percy.jpg" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size">test</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
"isValid": true,
"attributes": {
"url": "data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=",
"useFeaturedImage": false,
"alt": "",
"hasParallax": false,
"isRepeated": false,
"dimRatio": 40,
"backgroundType": "image",
"isRepeated": false,
"alt": "",
"isDark": true,
"tagName": "div"
},
"innerBlocks": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- wp:cover {"url":"data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=","dimRatio":40} -->
<div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-40 has-background-dim"></span><img class="wp-block-cover__image-background" alt="" src="data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim-40 has-background-dim"></span><img class="wp-block-cover__image-background" alt="" src="data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size">
Guten Berg!
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"isValid": true,
"attributes": {
"url": "data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=",
"useFeaturedImage": false,
"alt": "",
"hasParallax": false,
"isRepeated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"name": "core/cover",
"isValid": true,
"attributes": {
"useFeaturedImage": false,
"alt": "",
"hasParallax": false,
"isRepeated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"name": "core/cover",
"isValid": true,
"attributes": {
"useFeaturedImage": false,
"alt": "",
"hasParallax": false,
"isRepeated": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
"name": "core/gallery",
"isValid": true,
"attributes": {
"images": [],
"ids": [],
"shortCodeTransforms": [],
"columns": 2,
"caption": "",
"imageCrop": true,
"fixedHeight": true,
"linkTo": "none",
"align": "wide",
"allowResize": false
"sizeSlug": "large",
"allowResize": false,
"align": "wide"
},
"innerBlocks": [
{
Expand Down
23 changes: 21 additions & 2 deletions test/integration/fixtures/blocks/core__gallery__deprecated-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,30 @@
"name": "core/gallery",
"isValid": true,
"attributes": {
"images": [
{
"url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==",
"alt": "title",
"id": "1",
"caption": ""
},
{
"url": "data:image/jpeg;base64,/9j/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/yQALCAABAAEBAREA/8wABgAQEAX/2gAIAQEAAD8A0s8g/9k=",
"alt": "title",
"id": "2",
"caption": ""
}
],
"ids": [],
"shortCodeTransforms": [],
"columns": 2,
"caption": "",
"imageCrop": true,
"fixedHeight": true,
"linkTo": "none",
"align": "wide",
"allowResize": false
"sizeSlug": "large",
"allowResize": false,
"align": "wide"
},
"innerBlocks": [
{
Expand Down