Block Editor: Update the WordPress packages with the fixes for 5.8 beta 2.

This includes:

**Various**

 - Fix multi selection for nested blocks https://github.com/WordPress/gutenberg/pull/32536
 - Consistently show the drop indicator while dragging blocks https://github.com/WordPress/gutenberg/pull/31896
 - Fix horizontal drop indicator https://github.com/WordPress/gutenberg/pull/32589
 - Fix Safari flickering issue https://github.com/WordPress/gutenberg/pull/32581
 - Silence useSelect zombie bug errors https://github.com/WordPress/gutenberg/pull/32088

**Template Editor**

 - Clarify the template creation modal https://github.com/WordPress/gutenberg/pull/32427
 - Only add skip links for block templates https://github.com/WordPress/gutenberg/pull/32451

**Widgets Editor**

 - Add block breadcrumb https://github.com/WordPress/gutenberg/pull/32498 https://github.com/WordPress/gutenberg/pull/32528 https://github.com/WordPress/gutenberg/pull/32569
 - Saved deleted and restored widgets. https://github.com/WordPress/gutenberg/pull/32534
 - Fix unsaved changes detection https://github.com/WordPress/gutenberg/pull/32573
 - Fix button spacing in the header https://github.com/WordPress/gutenberg/pull/32585
 - Avoid extra undo levels https://github.com/WordPress/gutenberg/pull/32572
 - Move Legacy Widget block to the `@wordpress/widgets` package https://github.com/WordPress/gutenberg/pull/32501
 - Fix Social Links color inheritance https://github.com/WordPress/gutenberg/pull/32625
 - Use Button appender https://github.com/WordPress/gutenberg/pull/32580

**Global Styles (theme.json)**
 
 - Separate the presets per origin in the block editor settings https://github.com/WordPress/gutenberg/pull/32358 https://github.com/WordPress/gutenberg/pull/32622
 - Use CSS Custom Properties for the preset styles https://github.com/WordPress/gutenberg/pull/32627

**Performance**

 - Remove is-typing classname to improve typing performance https://github.com/WordPress/gutenberg/pull/32567

Props nosolosw, jorgefilipecosta, aristath, ntsekouras, peterwilsoncc, mcsf.
See #53397.


git-svn-id: https://develop.svn.wordpress.org/trunk@51149 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Riad Benguella 2021-06-15 08:50:26 +00:00
parent 15c8c705bc
commit 0068f2646c
20 changed files with 1243 additions and 1077 deletions

1673
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -78,56 +78,56 @@
},
"dependencies": {
"@wordpress/a11y": "3.1.1",
"@wordpress/annotations": "2.1.1",
"@wordpress/annotations": "2.1.2",
"@wordpress/api-fetch": "5.1.1",
"@wordpress/autop": "3.1.1",
"@wordpress/blob": "3.1.1",
"@wordpress/block-directory": "2.1.5",
"@wordpress/block-editor": "6.1.3",
"@wordpress/block-library": "3.2.4",
"@wordpress/block-directory": "2.1.7",
"@wordpress/block-editor": "6.1.4",
"@wordpress/block-library": "3.2.6",
"@wordpress/block-serialization-default-parser": "4.1.1",
"@wordpress/blocks": "9.1.3",
"@wordpress/components": "14.1.2",
"@wordpress/compose": "4.1.1",
"@wordpress/core-data": "3.1.4",
"@wordpress/customize-widgets": "1.0.4",
"@wordpress/data": "5.1.1",
"@wordpress/data-controls": "2.1.1",
"@wordpress/blocks": "9.1.4",
"@wordpress/components": "14.1.3",
"@wordpress/compose": "4.1.2",
"@wordpress/core-data": "3.1.6",
"@wordpress/customize-widgets": "1.0.6",
"@wordpress/data": "5.1.2",
"@wordpress/data-controls": "2.1.2",
"@wordpress/date": "4.1.1",
"@wordpress/deprecated": "3.1.1",
"@wordpress/dom": "3.1.1",
"@wordpress/dom-ready": "3.1.1",
"@wordpress/edit-post": "4.1.5",
"@wordpress/edit-widgets": "2.1.5",
"@wordpress/editor": "10.1.4",
"@wordpress/edit-post": "4.1.7",
"@wordpress/edit-widgets": "2.1.7",
"@wordpress/editor": "10.1.6",
"@wordpress/element": "3.1.1",
"@wordpress/escape-html": "2.1.1",
"@wordpress/format-library": "2.1.3",
"@wordpress/format-library": "2.1.4",
"@wordpress/hooks": "3.1.1",
"@wordpress/html-entities": "3.1.1",
"@wordpress/i18n": "4.1.1",
"@wordpress/icons": "4.0.1",
"@wordpress/interface": "3.1.2",
"@wordpress/interface": "3.1.3",
"@wordpress/is-shallow-equal": "4.1.1",
"@wordpress/keyboard-shortcuts": "2.1.1",
"@wordpress/keyboard-shortcuts": "2.1.2",
"@wordpress/keycodes": "3.1.1",
"@wordpress/list-reusable-blocks": "2.1.2",
"@wordpress/list-reusable-blocks": "2.1.3",
"@wordpress/media-utils": "2.1.1",
"@wordpress/notices": "3.1.1",
"@wordpress/nux": "4.1.2",
"@wordpress/plugins": "3.1.1",
"@wordpress/notices": "3.1.2",
"@wordpress/nux": "4.1.3",
"@wordpress/plugins": "3.1.2",
"@wordpress/primitives": "2.1.1",
"@wordpress/priority-queue": "2.1.1",
"@wordpress/redux-routine": "4.1.1",
"@wordpress/reusable-blocks": "2.1.4",
"@wordpress/rich-text": "4.1.1",
"@wordpress/server-side-render": "2.1.3",
"@wordpress/reusable-blocks": "2.1.6",
"@wordpress/rich-text": "4.1.2",
"@wordpress/server-side-render": "2.1.4",
"@wordpress/shortcode": "3.1.1",
"@wordpress/token-list": "2.1.1",
"@wordpress/url": "3.1.1",
"@wordpress/viewport": "3.1.1",
"@wordpress/viewport": "3.1.2",
"@wordpress/warning": "2.1.1",
"@wordpress/widgets": "1.1.4",
"@wordpress/widgets": "1.1.6",
"@wordpress/wordcount": "3.1.1",
"backbone": "1.4.0",
"clipboard": "2.0.8",

View File

@ -24,7 +24,10 @@ $preload_paths = array(
);
block_editor_rest_api_preload( $preload_paths, $block_editor_context );
$editor_settings = get_block_editor_settings( array(), $block_editor_context );
$editor_settings = get_block_editor_settings(
get_legacy_widget_block_editor_settings(),
$block_editor_context
);
wp_add_inline_script(
'wp-edit-widgets',

File diff suppressed because one or more lines are too long

View File

@ -225,6 +225,20 @@ function get_default_block_editor_settings() {
$editor_settings['gradients'] = $gradient_presets;
}
return $editor_settings;
}
/**
* Returns the block editor settings needed to use the Legacy Widget block which
* is not registered by default.
*
* @since 5.8.0
*
* @return array Settings to be used with get_block_editor_settings().
*/
function get_legacy_widget_block_editor_settings() {
$editor_settings = array();
/**
* Filters the list of widget-type IDs that should **not** be offered by the
* Legacy Widget block.
@ -296,13 +310,32 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
$editor_settings['__experimentalFeatures'] = $theme_json->get_settings();
// These settings may need to be updated based on data coming from theme.json sources.
if ( isset( $editor_settings['__experimentalFeatures']['color']['palette'] ) ) {
$editor_settings['colors'] = $editor_settings['__experimentalFeatures']['color']['palette'];
unset( $editor_settings['__experimentalFeatures']['color']['palette'] );
if ( isset( $settings['__experimentalFeatures']['color']['palette'] ) ) {
$colors_by_origin = $settings['__experimentalFeatures']['color']['palette'];
$settings['colors'] = isset( $colors_by_origin['user'] ) ?
$colors_by_origin['user'] : (
isset( $colors_by_origin['theme'] ) ?
$colors_by_origin['theme'] :
$colors_by_origin['core']
);
}
if ( isset( $editor_settings['__experimentalFeatures']['color']['gradients'] ) ) {
$editor_settings['gradients'] = $editor_settings['__experimentalFeatures']['color']['gradients'];
unset( $editor_settings['__experimentalFeatures']['color']['gradients'] );
if ( isset( $settings['__experimentalFeatures']['color']['gradients'] ) ) {
$gradients_by_origin = $settings['__experimentalFeatures']['color']['gradients'];
$settings['gradients'] = isset( $gradients_by_origin['user'] ) ?
$gradients_by_origin['user'] : (
isset( $gradients_by_origin['theme'] ) ?
$gradients_by_origin['theme'] :
$gradients_by_origin['core']
);
}
if ( isset( $settings['__experimentalFeatures']['typography']['fontSizes'] ) ) {
$font_sizes_by_origin = $settings['__experimentalFeatures']['typography']['fontSizes'];
$settings['fontSizes'] = isset( $font_sizes_by_origin['user'] ) ?
$font_sizes_by_origin['user'] : (
isset( $font_sizes_by_origin['theme'] ) ?
$font_sizes_by_origin['theme'] :
$font_sizes_by_origin['core']
);
}
if ( isset( $editor_settings['__experimentalFeatures']['color']['custom'] ) ) {
$editor_settings['disableCustomColors'] = ! $editor_settings['__experimentalFeatures']['color']['custom'];
@ -312,10 +345,6 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
$editor_settings['disableCustomGradients'] = ! $editor_settings['__experimentalFeatures']['color']['customGradient'];
unset( $editor_settings['__experimentalFeatures']['color']['customGradient'] );
}
if ( isset( $editor_settings['__experimentalFeatures']['typography']['fontSizes'] ) ) {
$editor_settings['fontSizes'] = $editor_settings['__experimentalFeatures']['typography']['fontSizes'];
unset( $editor_settings['__experimentalFeatures']['typography']['fontSizes'] );
}
if ( isset( $editor_settings['__experimentalFeatures']['typography']['customFontSize'] ) ) {
$editor_settings['disableCustomFontSizes'] = ! $editor_settings['__experimentalFeatures']['typography']['customFontSize'];
unset( $editor_settings['__experimentalFeatures']['typography']['customFontSize'] );

View File

@ -5,7 +5,7 @@
"category": "design",
"description": "Displays the contents of a post or page.",
"textdomain": "default",
"usesContext": [ "postId", "postType" ],
"usesContext": [ "postId", "postType", "queryId" ],
"supports": {
"align": [ "wide", "full" ],
"html": false,

View File

@ -17,7 +17,7 @@
"default": false
}
},
"usesContext": [ "postId", "postType" ],
"usesContext": [ "postId", "postType", "queryId" ],
"supports": {
"html": false,
"color": {

View File

@ -21,7 +21,7 @@
"default": true
}
},
"usesContext": [ "postId", "postType" ],
"usesContext": [ "postId", "postType", "queryId" ],
"supports": {
"html": false,
"color": {

View File

@ -11,7 +11,7 @@
"default": false
}
},
"usesContext": [ "postId", "postType" ],
"usesContext": [ "postId", "postType", "queryId" ],
"supports": {
"align": [ "left", "right", "center", "wide", "full" ],
"html": false

View File

@ -5,7 +5,7 @@
"category": "design",
"description": "Displays the title of a post, page, or any other content-type.",
"textdomain": "default",
"usesContext": [ "postId", "postType" ],
"usesContext": [ "postId", "postType", "queryId" ],
"attributes": {
"textAlign": {
"type": "string"

View File

@ -837,7 +837,10 @@ final class WP_Customize_Widgets {
if ( wp_use_widgets_block_editor() ) {
$block_editor_context = new WP_Block_Editor_Context();
$editor_settings = get_block_editor_settings( array(), $block_editor_context );
$editor_settings = get_block_editor_settings(
get_legacy_widget_block_editor_settings(),
$block_editor_context
);
wp_add_inline_script(
'wp-customize-widgets',

View File

@ -248,7 +248,7 @@ class WP_Theme_JSON_Resolver {
$config = self::read_json_file( __DIR__ . '/theme.json' );
$config = self::translate( $config );
self::$core = new WP_Theme_JSON( $config );
self::$core = new WP_Theme_JSON( $config, 'core' );
return self::$core;
}
@ -301,7 +301,7 @@ class WP_Theme_JSON_Resolver {
*
* @since 5.8.0
*
* @param array $settings Existing block editor settings.
* @param array $settings Existing block editor settings.
* Empty array by default.
* @return WP_Theme_JSON
*/

View File

@ -40,6 +40,12 @@ class WP_Theme_JSON {
*/
const ROOT_BLOCK_SELECTOR = 'body';
const VALID_ORIGINS = array(
'core',
'theme',
'user',
);
/**
* Presets are a set of values that serve
* to bootstrap some styles: colors, font sizes, etc.
@ -246,14 +252,31 @@ class WP_Theme_JSON {
* @since 5.8.0
*
* @param array $theme_json A structure that follows the theme.json schema.
* @param string $origin What source of data this object represents. One of core, theme, or user. Default: theme.
*/
public function __construct( $theme_json = array() ) {
public function __construct( $theme_json = array(), $origin = 'theme' ) {
if ( ! in_array( $origin, self::VALID_ORIGINS, true ) ) {
$origin = 'theme';
}
if ( ! isset( $theme_json['version'] ) || self::LATEST_SCHEMA !== $theme_json['version'] ) {
$this->theme_json = array();
return;
}
$this->theme_json = self::sanitize( $theme_json );
// Internally, presets are keyed by origin.
$nodes = self::get_setting_nodes( $this->theme_json );
foreach ( $nodes as $node ) {
foreach ( self::PRESETS_METADATA as $preset ) {
$path = array_merge( $node['path'], $preset['path'] );
$preset = _wp_array_get( $this->theme_json, $path, null );
if ( null !== $preset ) {
_wp_array_set( $this->theme_json, $path, array( $origin => $preset ) );
}
}
}
}
/**
@ -631,6 +654,32 @@ class WP_Theme_JSON {
return implode( ',', $new_selectors );
}
/**
* Given an array of presets keyed by origin and the value key of the preset,
* it returns an array where each key is the preset slug and each value the preset value.
*
* @param array $preset_per_origin Array of presets keyed by origin.
* @param string $value_key The property of the preset that contains its value.
*
* @return array Array of presets where each key is a slug and each value is the preset value.
*/
private static function get_merged_preset_by_slug( $preset_per_origin, $value_key ) {
$result = array();
foreach ( self::VALID_ORIGINS as $origin ) {
if ( ! isset( $preset_per_origin[ $origin ] ) ) {
continue;
}
foreach ( $preset_per_origin[ $origin ] as $preset ) {
// We don't want to use kebabCase here,
// see https://github.com/WordPress/gutenberg/issues/32347
// However, we need to make sure the generated class or css variable
// doesn't contain spaces.
$result[ preg_replace( '/\s+/', '-', $preset['slug'] ) ] = $preset[ $value_key ];
}
}
return $result;
}
/**
* Given a settings array, it returns the generated rulesets
* for the preset classes.
@ -651,19 +700,16 @@ class WP_Theme_JSON {
$stylesheet = '';
foreach ( self::PRESETS_METADATA as $preset ) {
$values = _wp_array_get( $settings, $preset['path'], array() );
foreach ( $values as $value ) {
foreach ( $preset['classes'] as $class ) {
$preset_per_origin = _wp_array_get( $settings, $preset['path'], array() );
$preset_by_slug = self::get_merged_preset_by_slug( $preset_per_origin, $preset['value_key'] );
foreach ( $preset['classes'] as $class ) {
foreach ( $preset_by_slug as $slug => $value ) {
$stylesheet .= self::to_ruleset(
// We don't want to use kebabCase here,
// see https://github.com/WordPress/gutenberg/issues/32347
// However, we need to make sure the generated class
// doesn't contain spaces.
self::append_to_selector( $selector, '.has-' . preg_replace( '/\s+/', '-', $value['slug'] ) . '-' . $class['class_suffix'] ),
self::append_to_selector( $selector, '.has-' . $slug . '-' . $class['class_suffix'] ),
array(
array(
'name' => $class['property_name'],
'value' => $value[ $preset['value_key'] ] . ' !important',
'value' => $value . ' !important',
),
)
);
@ -695,11 +741,12 @@ class WP_Theme_JSON {
private static function compute_preset_vars( $settings ) {
$declarations = array();
foreach ( self::PRESETS_METADATA as $preset ) {
$values = _wp_array_get( $settings, $preset['path'], array() );
foreach ( $values as $value ) {
$preset_per_origin = _wp_array_get( $settings, $preset['path'], array() );
$preset_by_slug = self::get_merged_preset_by_slug( $preset_per_origin, $preset['value_key'] );
foreach ( $preset_by_slug as $slug => $value ) {
$declarations[] = array(
'name' => '--wp--preset--' . $preset['css_var_infix'] . '--' . $value['slug'],
'value' => $value[ $preset['value_key'] ],
'name' => '--wp--preset--' . $preset['css_var_infix'] . '--' . $slug,
'value' => $value,
);
}
}
@ -1039,88 +1086,36 @@ class WP_Theme_JSON {
/**
* Merge new incoming data.
*
* @since 5.8.0
*
* @param WP_Theme_JSON $incoming Data to merge.
*/
public function merge( $incoming, $update_or_remove = 'remove' ) {
$incoming_data = $incoming->get_raw_data();
$existing_data = $this->theme_json;
public function merge( $incoming ) {
$incoming_data = $incoming->get_raw_data();
$this->theme_json = array_replace_recursive( $this->theme_json, $incoming_data );
// The array_replace_recursive algorithm merges at the leaf level.
// For leaf values that are arrays it will use the numeric indexes for replacement.
$this->theme_json = array_replace_recursive( $this->theme_json, $incoming_data );
// There are a few cases in which we want to merge things differently
// from what array_replace_recursive does.
// Some incoming properties should replace the existing.
// In those cases, we want to replace the existing with the incoming value, if it exists.
$to_replace = array();
$to_replace[] = array( 'custom' );
$to_replace[] = array( 'spacing', 'units' );
$to_replace[] = array( 'typography', 'fontSizes' );
$to_replace[] = array( 'typography', 'fontFamilies' );
// Some others should be appended to the existing.
// If the slug is the same than an existing element,
// the $update_or_remove param is used to decide
// what to do with the existing element:
// either remove it and append the incoming,
// or update it with the incoming.
$to_append = array();
$to_append[] = array( 'color', 'duotone' );
$to_append[] = array( 'color', 'gradients' );
$to_append[] = array( 'color', 'palette' );
$to_replace[] = array( 'color', 'duotone' );
foreach ( self::VALID_ORIGINS as $origin ) {
$to_replace[] = array( 'color', 'palette', $origin );
$to_replace[] = array( 'color', 'gradients', $origin );
$to_replace[] = array( 'typography', 'fontSizes', $origin );
$to_replace[] = array( 'typography', 'fontFamilies', $origin );
}
$nodes = self::get_setting_nodes( $this->theme_json );
foreach ( $nodes as $metadata ) {
foreach ( $to_replace as $path_to_replace ) {
$path = array_merge( $metadata['path'], $path_to_replace );
foreach ( $to_replace as $property_path ) {
$path = array_merge( $metadata['path'], $property_path );
$node = _wp_array_get( $incoming_data, $path, array() );
if ( ! empty( $node ) ) {
_wp_array_set( $this->theme_json, $path, $node );
}
}
foreach ( $to_append as $path_to_append ) {
$path = array_merge( $metadata['path'], $path_to_append );
$incoming_node = _wp_array_get( $incoming_data, $path, array() );
$existing_node = _wp_array_get( $existing_data, $path, array() );
if ( empty( $incoming_node ) && empty( $existing_node ) ) {
continue;
}
$index_table = array();
$existing_slugs = array();
$merged = array();
foreach ( $existing_node as $key => $value ) {
$index_table[ $value['slug'] ] = $key;
$existing_slugs[] = $value['slug'];
$merged[ $key ] = $value;
}
$to_remove = array();
foreach ( $incoming_node as $value ) {
if ( ! in_array( $value['slug'], $existing_slugs, true ) ) {
$merged[] = $value;
} elseif ( 'update' === $update_or_remove ) {
$merged[ $index_table[ $value['slug'] ] ] = $value;
} else {
$merged[] = $value;
$to_remove[] = $index_table[ $value['slug'] ];
}
}
// Remove the duplicated values and pack the sparsed array.
foreach ( $to_remove as $index ) {
unset( $merged[ $index ] );
}
$merged = array_values( $merged );
_wp_array_set( $this->theme_json, $path, $merged );
}
}
}
/**

View File

@ -1553,15 +1553,18 @@ function wp_default_styles( $styles ) {
'list-reusable-blocks' => array( 'wp-components' ),
'reusable-blocks' => array( 'wp-components' ),
'nux' => array( 'wp-components' ),
'edit-widgets' => array(
'widgets' => array(
'wp-components',
),
'edit-widgets' => array(
'wp-widgets',
'wp-block-editor',
'wp-edit-blocks',
'wp-block-library',
'wp-reusable-blocks',
),
'customize-widgets' => array(
'wp-components',
'wp-widgets',
'wp-block-editor',
'wp-edit-blocks',
'wp-block-library',
@ -1622,12 +1625,15 @@ function wp_default_styles( $styles ) {
'wp-block-library',
'wp-block-directory',
'wp-components',
'wp-customize-widgets',
'wp-edit-post',
'wp-edit-widgets',
'wp-editor',
'wp-format-library',
'wp-list-reusable-blocks',
'wp-reusable-blocks',
'wp-nux',
'wp-widgets',
// Deprecated CSS.
'deprecated-media',
'farbtastic',

View File

@ -76,10 +76,16 @@ function wp_filter_wp_template_unique_post_slug( $override_slug, $slug, $post_ID
*/
function the_block_template_skip_link() {
// Early exit if not an FSE theme.
// Early exit if not a block theme.
if ( ! current_theme_supports( 'block-templates' ) ) {
return;
}
// Early exit if not a block template.
global $_wp_current_template_content;
if ( ! $_wp_current_template_content ) {
return;
}
?>
<?php
@ -137,7 +143,12 @@ function the_block_template_skip_link() {
// Get the site wrapper.
// The skip-link will be injected in the beginning of it.
parentEl = document.querySelector( '.wp-site-blocks' ) || document.body,
parentEl = document.querySelector( '.wp-site-blocks' );
// Early exit if the root element was not found.
if ( ! parentEl ) {
return;
}
// Get the skip-link target's ID, and generate one if it doesn't exist.
skipLinkTargetID = skipLinkTarget.id;

View File

@ -50,74 +50,62 @@
{
"name": "Vivid cyan blue to vivid purple",
"gradient": "linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)",
"slug": "vivid-cyan-blue-to-vivid-purple",
"origin": "core"
"slug": "vivid-cyan-blue-to-vivid-purple"
},
{
"name": "Light green cyan to vivid green cyan",
"gradient": "linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)",
"slug": "light-green-cyan-to-vivid-green-cyan",
"origin": "core"
"slug": "light-green-cyan-to-vivid-green-cyan"
},
{
"name": "Luminous vivid amber to luminous vivid orange",
"gradient": "linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)",
"slug": "luminous-vivid-amber-to-luminous-vivid-orange",
"origin": "core"
"slug": "luminous-vivid-amber-to-luminous-vivid-orange"
},
{
"name": "Luminous vivid orange to vivid red",
"gradient": "linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%)",
"slug": "luminous-vivid-orange-to-vivid-red",
"origin": "core"
"slug": "luminous-vivid-orange-to-vivid-red"
},
{
"name": "Very light gray to cyan bluish gray",
"gradient": "linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%)",
"slug": "very-light-gray-to-cyan-bluish-gray",
"origin": "core"
"slug": "very-light-gray-to-cyan-bluish-gray"
},
{
"name": "Cool to warm spectrum",
"gradient": "linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%)",
"slug": "cool-to-warm-spectrum",
"origin": "core"
"slug": "cool-to-warm-spectrum"
},
{
"name": "Blush light purple",
"gradient": "linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%)",
"slug": "blush-light-purple",
"origin": "core"
"slug": "blush-light-purple"
},
{
"name": "Blush bordeaux",
"gradient": "linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)",
"slug": "blush-bordeaux",
"origin": "core"
"slug": "blush-bordeaux"
},
{
"name": "Luminous dusk",
"gradient": "linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%)",
"slug": "luminous-dusk",
"origin": "core"
"slug": "luminous-dusk"
},
{
"name": "Pale ocean",
"gradient": "linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%)",
"slug": "pale-ocean",
"origin": "core"
"slug": "pale-ocean"
},
{
"name": "Electric grass",
"gradient": "linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%)",
"slug": "electric-grass",
"origin": "core"
"slug": "electric-grass"
},
{
"name": "Midnight",
"gradient": "linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%)",
"slug": "midnight",
"origin": "core"
"slug": "midnight"
}
],
"link": false,
@ -125,74 +113,62 @@
{
"name": "Black",
"slug": "black",
"color": "#000000",
"origin": "core"
"color": "#000000"
},
{
"name": "Cyan bluish gray",
"slug": "cyan-bluish-gray",
"color": "#abb8c3",
"origin": "core"
"color": "#abb8c3"
},
{
"name": "White",
"slug": "white",
"color": "#ffffff",
"origin": "core"
"color": "#ffffff"
},
{
"name": "Pale pink",
"slug": "pale-pink",
"color": "#f78da7",
"origin": "core"
"color": "#f78da7"
},
{
"name": "Vivid red",
"slug": "vivid-red",
"color": "#cf2e2e",
"origin": "core"
"color": "#cf2e2e"
},
{
"name": "Luminous vivid orange",
"slug": "luminous-vivid-orange",
"color": "#ff6900",
"origin": "core"
"color": "#ff6900"
},
{
"name": "Luminous vivid amber",
"slug": "luminous-vivid-amber",
"color": "#fcb900",
"origin": "core"
"color": "#fcb900"
},
{
"name": "Light green cyan",
"slug": "light-green-cyan",
"color": "#7bdcb5",
"origin": "core"
"color": "#7bdcb5"
},
{
"name": "Vivid green cyan",
"slug": "vivid-green-cyan",
"color": "#00d084",
"origin": "core"
"color": "#00d084"
},
{
"name": "Pale cyan blue",
"slug": "pale-cyan-blue",
"color": "#8ed1fc",
"origin": "core"
"color": "#8ed1fc"
},
{
"name": "Vivid cyan blue",
"slug": "vivid-cyan-blue",
"color": "#0693e3",
"origin": "core"
"color": "#0693e3"
},
{
"name": "Vivid purple",
"slug": "vivid-purple",
"color": "#9b51e0",
"origin": "core"
"color": "#9b51e0"
}
]
},

View File

@ -170,7 +170,7 @@ class WP_Test_Block_Editor extends WP_UnitTestCase {
function test_get_default_block_editor_settings() {
$settings = get_default_block_editor_settings();
$this->assertCount( 17, $settings );
$this->assertCount( 16, $settings );
$this->assertFalse( $settings['alignWide'] );
$this->assertInternalType( 'array', $settings['allowedMimeTypes'] );
$this->assertTrue( $settings['allowedBlockTypes'] );
@ -265,6 +265,14 @@ class WP_Test_Block_Editor extends WP_UnitTestCase {
$settings['imageSizes']
);
$this->assertInternalType( 'int', $settings['maxUploadFileSize'] );
}
/**
* @ticket 53397
*/
function test_get_legacy_widget_block_editor_settings() {
$settings = get_legacy_widget_block_editor_settings();
$this->assertCount( 1, $settings );
$this->assertSameSets(
array(
'archives',

View File

@ -64,12 +64,137 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
$this->assertSameSetsWithIndex( $expected, $actual );
}
function test_get_settings_presets_are_keyed_by_origin() {
$core_origin = new WP_Theme_JSON(
array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'palette' => array(
array(
'slug' => 'white',
'color' => 'white',
),
),
),
'invalid/key' => 'value',
'blocks' => array(
'core/group' => array(
'color' => array(
'palette' => array(
array(
'slug' => 'white',
'color' => 'white',
),
),
),
),
),
),
),
'core'
);
$no_origin = new WP_Theme_JSON(
array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'palette' => array(
array(
'slug' => 'black',
'color' => 'black',
),
),
),
'invalid/key' => 'value',
'blocks' => array(
'core/group' => array(
'color' => array(
'palette' => array(
array(
'slug' => 'black',
'color' => 'black',
),
),
),
),
),
),
)
);
$actual_core = $core_origin->get_raw_data();
$actual_no_origin = $no_origin->get_raw_data();
$expected_core = array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'palette' => array(
'core' => array(
array(
'slug' => 'white',
'color' => 'white',
),
),
),
),
'blocks' => array(
'core/group' => array(
'color' => array(
'palette' => array(
'core' => array(
array(
'slug' => 'white',
'color' => 'white',
),
),
),
),
),
),
),
);
$expected_no_origin = array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'palette' => array(
'theme' => array(
array(
'slug' => 'black',
'color' => 'black',
),
),
),
),
'blocks' => array(
'core/group' => array(
'color' => array(
'palette' => array(
'theme' => array(
array(
'slug' => 'black',
'color' => 'black',
),
),
),
),
),
),
),
);
$this->assertEqualSetsWithIndex( $expected_core, $actual_core );
$this->assertEqualSetsWithIndex( $expected_no_origin, $actual_no_origin );
}
function test_get_stylesheet() {
$theme_json = new WP_Theme_JSON(
array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'color' => array(
'text' => 'value',
'palette' => array(
array(
@ -78,8 +203,20 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
),
),
),
'misc' => 'value',
'blocks' => array(
'typography' => array(
'fontFamilies' => array(
array(
'slug' => 'small',
'fontFamily' => '14px',
),
array(
'slug' => 'big',
'fontFamily' => '41px',
),
),
),
'misc' => 'value',
'blocks' => array(
'core/group' => array(
'custom' => array(
'base-font' => 16,
@ -265,7 +402,8 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
),
),
),
)
),
'core'
);
$this->assertSame(
@ -278,35 +416,37 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
* @ticket 52991
*/
public function test_merge_incoming_data() {
$initial = array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'custom' => false,
'palette' => array(
array(
'slug' => 'red',
'color' => 'red',
$theme_json = new WP_Theme_JSON(
array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'custom' => false,
'palette' => array(
array(
'slug' => 'red',
'color' => 'red',
),
array(
'slug' => 'green',
'color' => 'green',
),
),
array(
'slug' => 'green',
'color' => 'green',
),
'blocks' => array(
'core/paragraph' => array(
'color' => array(
'custom' => false,
),
),
),
),
'blocks' => array(
'core/paragraph' => array(
'color' => array(
'custom' => false,
),
'styles' => array(
'typography' => array(
'fontSize' => '12',
),
),
),
'styles' => array(
'typography' => array(
'fontSize' => '12',
),
),
)
);
$add_new_block = array(
@ -436,31 +576,29 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
'custom' => true,
'customGradient' => true,
'palette' => array(
array(
'slug' => 'red',
'color' => 'red',
),
array(
'slug' => 'green',
'color' => 'green',
),
array(
'slug' => 'blue',
'color' => 'blue',
'theme' => array(
array(
'slug' => 'blue',
'color' => 'blue',
),
),
),
'gradients' => array(
array(
'slug' => 'gradient',
'gradient' => 'gradient',
'theme' => array(
array(
'slug' => 'gradient',
'gradient' => 'gradient',
),
),
),
),
'typography' => array(
'fontSizes' => array(
array(
'slug' => 'fontSize',
'size' => 'fontSize',
'theme' => array(
array(
'slug' => 'fontSize',
'size' => 'fontSize',
),
),
),
),
@ -502,7 +640,6 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
),
);
$theme_json = new WP_Theme_JSON( $initial );
$theme_json->merge( new WP_Theme_JSON( $add_new_block ) );
$theme_json->merge( new WP_Theme_JSON( $add_key_in_settings ) );
$theme_json->merge( new WP_Theme_JSON( $update_key_in_settings ) );

View File

@ -110,15 +110,17 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase {
array(
'color' => array(
'palette' => array(
array(
'slug' => 'light',
'name' => 'Jasny',
'color' => '#f5f7f9',
),
array(
'slug' => 'dark',
'name' => 'Ciemny',
'color' => '#000',
'theme' => array(
array(
'slug' => 'light',
'name' => 'Jasny',
'color' => '#f5f7f9',
),
array(
'slug' => 'dark',
'name' => 'Ciemny',
'color' => '#000',
),
),
),
'custom' => false,
@ -127,10 +129,12 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase {
'core/paragraph' => array(
'color' => array(
'palette' => array(
array(
'slug' => 'light',
'name' => 'Jasny',
'color' => '#f5f7f9',
'theme' => array(
array(
'slug' => 'light',
'name' => 'Jasny',
'color' => '#f5f7f9',
),
),
),
),

View File

@ -112,7 +112,6 @@ module.exports = function( env = { environment: 'production', watch: false, buil
'file',
'latest-comments',
'latest-posts',
'legacy-widget',
'loginout',
'page-list',
'post-content',
@ -172,12 +171,14 @@ module.exports = function( env = { environment: 'production', watch: false, buil
];
const phpFiles = {
'block-serialization-default-parser/parser.php': 'wp-includes/class-wp-block-parser.php',
'widgets/src/blocks/legacy-widget/index.php': 'wp-includes/blocks/legacy-widget.php',
...dynamicBlockFolders.reduce( ( files, blockName ) => {
files[ `block-library/src/${ blockName }/index.php` ] = `wp-includes/blocks/${ blockName }.php`;
return files;
} , {} ),
};
const blockMetadataFiles = {
'widgets/src/blocks/legacy-widget/block.json': 'wp-includes/blocks/legacy-widget/block.json',
...blockFolders.reduce( ( files, blockName ) => {
files[ `block-library/src/${ blockName }/block.json` ] = `wp-includes/blocks/${ blockName }/block.json`;
return files;