Editor: Update WordPress packages from Gutenberg 10.5

Applies changes between the Gutenberg plugin v10.4 and v10.5. It contains the latest version of WordPress packages and PHP changes applied to non-experimental features.

Props youknowriad.
See #52991.



git-svn-id: https://develop.svn.wordpress.org/trunk@50824 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Greg Ziółkowski 2021-05-07 11:46:32 +00:00
parent 524f2b1f23
commit 154c0800e3
29 changed files with 1751 additions and 975 deletions

2306
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -26,9 +26,9 @@
"devDependencies": {
"@wordpress/custom-templated-path-webpack-plugin": "2.0.3",
"@wordpress/dependency-extraction-webpack-plugin": "3.1.2",
"@wordpress/e2e-test-utils": "5.1.2",
"@wordpress/e2e-test-utils": "5.1.3",
"@wordpress/library-export-default-webpack-plugin": "2.0.3",
"@wordpress/scripts": "14.1.1",
"@wordpress/scripts": "15.0.1",
"autoprefixer": "^9.8.6",
"chalk": "4.1.0",
"check-node-version": "4.1.0",
@ -77,53 +77,53 @@
},
"dependencies": {
"@babel/polyfill": "7.10.1",
"@wordpress/a11y": "2.15.2",
"@wordpress/annotations": "1.25.2",
"@wordpress/api-fetch": "3.23.1",
"@wordpress/a11y": "2.15.3",
"@wordpress/annotations": "1.25.3",
"@wordpress/api-fetch": "4.0.0",
"@wordpress/autop": "2.12.2",
"@wordpress/blob": "2.13.2",
"@wordpress/block-directory": "1.19.2",
"@wordpress/block-editor": "5.3.2",
"@wordpress/block-library": "2.29.2",
"@wordpress/block-directory": "1.19.3",
"@wordpress/block-editor": "5.3.3",
"@wordpress/block-library": "2.29.3",
"@wordpress/block-serialization-default-parser": "3.10.2",
"@wordpress/blocks": "8.0.2",
"@wordpress/components": "13.0.2",
"@wordpress/compose": "3.25.2",
"@wordpress/core-data": "2.26.2",
"@wordpress/data": "4.27.2",
"@wordpress/data-controls": "1.21.2",
"@wordpress/blocks": "8.0.3",
"@wordpress/components": "13.0.3",
"@wordpress/compose": "3.25.3",
"@wordpress/core-data": "2.26.3",
"@wordpress/data": "4.27.3",
"@wordpress/data-controls": "1.21.3",
"@wordpress/date": "3.15.1",
"@wordpress/deprecated": "2.12.2",
"@wordpress/dom": "2.17.2",
"@wordpress/deprecated": "2.12.3",
"@wordpress/dom": "2.18.0",
"@wordpress/dom-ready": "2.13.2",
"@wordpress/edit-post": "3.27.2",
"@wordpress/editor": "9.26.2",
"@wordpress/element": "2.20.2",
"@wordpress/edit-post": "3.27.3",
"@wordpress/editor": "9.26.3",
"@wordpress/element": "2.20.3",
"@wordpress/escape-html": "1.12.2",
"@wordpress/format-library": "1.27.2",
"@wordpress/hooks": "2.12.2",
"@wordpress/format-library": "1.27.3",
"@wordpress/hooks": "2.12.3",
"@wordpress/html-entities": "2.11.2",
"@wordpress/i18n": "3.19.2",
"@wordpress/icons": "2.10.2",
"@wordpress/interface": "2.0.1",
"@wordpress/is-shallow-equal": "3.1.2",
"@wordpress/keyboard-shortcuts": "1.14.2",
"@wordpress/keycodes": "2.19.2",
"@wordpress/list-reusable-blocks": "1.26.2",
"@wordpress/media-utils": "1.20.2",
"@wordpress/notices": "2.13.2",
"@wordpress/nux": "3.25.2",
"@wordpress/plugins": "2.25.2",
"@wordpress/primitives": "1.12.2",
"@wordpress/i18n": "3.20.0",
"@wordpress/icons": "2.10.3",
"@wordpress/interface": "2.0.2",
"@wordpress/is-shallow-equal": "3.1.3",
"@wordpress/keyboard-shortcuts": "1.14.3",
"@wordpress/keycodes": "2.19.3",
"@wordpress/list-reusable-blocks": "1.26.3",
"@wordpress/media-utils": "1.20.3",
"@wordpress/notices": "2.13.3",
"@wordpress/nux": "3.25.3",
"@wordpress/plugins": "2.25.3",
"@wordpress/primitives": "1.12.3",
"@wordpress/priority-queue": "1.11.2",
"@wordpress/redux-routine": "3.14.2",
"@wordpress/reusable-blocks": "1.2.2",
"@wordpress/rich-text": "3.25.2",
"@wordpress/server-side-render": "1.21.2",
"@wordpress/reusable-blocks": "1.2.3",
"@wordpress/rich-text": "3.25.3",
"@wordpress/server-side-render": "1.21.3",
"@wordpress/shortcode": "2.13.2",
"@wordpress/token-list": "1.15.2",
"@wordpress/token-list": "1.15.3",
"@wordpress/url": "2.22.2",
"@wordpress/viewport": "2.26.2",
"@wordpress/viewport": "2.26.3",
"@wordpress/warning": "1.4.2",
"@wordpress/wordcount": "2.15.2",
"backbone": "1.4.0",

File diff suppressed because one or more lines are too long

View File

@ -7,29 +7,35 @@
*/
/**
* Registers the style attribute used by the border feature if needed for block types that
* support borders.
* Registers the style attribute used by the border feature if needed for block
* types that support borders.
*
* @since 5.8.0
* @access private
* @since 5.8.0
* @access private
*
* @param WP_Block_Type $block_type Block Type.
*/
function wp_register_border_support( $block_type ) {
// Determine border related features supported.
// Border width, style etc can be added in the future.
$has_border_radius_support = block_has_support( $block_type, array( '__experimentalBorder', 'radius' ), false );
// Determine if any border related features are supported.
$has_border_support = block_has_support( $block_type, array( '__experimentalBorder' ) );
$has_border_color_support = block_has_support( $block_type, array( '__experimentalBorder', 'color' ) );
// Setup attributes and styles within that if needed.
if ( ! $block_type->attributes ) {
$block_type->attributes = array();
}
if ( $has_border_radius_support && ! array_key_exists( 'style', $block_type->attributes ) ) {
if ( $has_border_support && ! array_key_exists( 'style', $block_type->attributes ) ) {
$block_type->attributes['style'] = array(
'type' => 'object',
);
}
if ( $has_border_color_support && ! array_key_exists( 'borderColor', $block_type->attributes ) ) {
$block_type->attributes['borderColor'] = array(
'type' => 'string',
);
}
}
/**
@ -45,33 +51,64 @@ function wp_register_border_support( $block_type ) {
* @return array Border CSS classes and inline styles.
*/
function wp_apply_border_support( $block_type, $block_attributes ) {
$border_support = _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), false );
if (
is_array( $border_support ) &&
array_key_exists( '__experimentalSkipSerialization', $border_support ) &&
$border_support['__experimentalSkipSerialization']
) {
if ( wp_skip_border_serialization( $block_type ) ) {
return array();
}
// Arrays used to ease addition of further border related features in future.
$styles = array();
$classes = array();
$styles = array();
// Border Radius.
$has_border_radius_support = block_has_support( $block_type, array( '__experimentalBorder', 'radius' ), false );
if ( $has_border_radius_support ) {
if ( isset( $block_attributes['style']['border']['radius'] ) ) {
$border_radius = intval( $block_attributes['style']['border']['radius'] );
$styles[] = sprintf( 'border-radius: %dpx;', $border_radius );
// Border radius.
if (
block_has_support( $block_type, array( '__experimentalBorder', 'radius' ) ) &&
isset( $block_attributes['style']['border']['radius'] )
) {
$border_radius = (int) $block_attributes['style']['border']['radius'];
$styles[] = sprintf( 'border-radius: %dpx;', $border_radius );
}
// Border style.
if (
block_has_support( $block_type, array( '__experimentalBorder', 'style' ) ) &&
isset( $block_attributes['style']['border']['style'] )
) {
$border_style = $block_attributes['style']['border']['style'];
$styles[] = sprintf( 'border-style: %s;', $border_style );
}
// Border width.
if (
block_has_support( $block_type, array( '__experimentalBorder', 'width' ) ) &&
isset( $block_attributes['style']['border']['width'] )
) {
$border_width = intval( $block_attributes['style']['border']['width'] );
$styles[] = sprintf( 'border-width: %dpx;', $border_width );
}
// Border color.
if ( block_has_support( $block_type, array( '__experimentalBorder', 'color' ) ) ) {
$has_named_border_color = array_key_exists( 'borderColor', $block_attributes );
$has_custom_border_color = isset( $block_attributes['style']['border']['color'] );
if ( $has_named_border_color || $has_custom_border_color ) {
$classes[] = 'has-border-color';
}
if ( $has_named_border_color ) {
$classes[] = sprintf( 'has-%s-border-color', $block_attributes['borderColor'] );
} elseif ( $has_custom_border_color ) {
$border_color = $block_attributes['style']['border']['color'];
$styles[] = sprintf( 'border-color: %s;', $border_color );
}
}
// Border width, style etc can be added here.
// Collect classes and styles.
$attributes = array();
if ( ! empty( $classes ) ) {
$attributes['class'] = implode( ' ', $classes );
}
if ( ! empty( $styles ) ) {
$attributes['style'] = implode( ' ', $styles );
}
@ -79,6 +116,25 @@ function wp_apply_border_support( $block_type, $block_attributes ) {
return $attributes;
}
/**
* Checks whether serialization of the current block's border properties should
* occur.
*
* @since 5.8.0
* @access private
*
* @param WP_Block_type $block_type Block type.
*
* @return boolean
*/
function wp_skip_border_serialization( $block_type ) {
$border_support = _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), false );
return is_array( $border_support ) &&
array_key_exists( '__experimentalSkipSerialization', $border_support ) &&
$border_support['__experimentalSkipSerialization'];
}
// Register the block support.
WP_Block_Supports::get_instance()->register(
'border',

View File

@ -88,7 +88,7 @@ function wp_apply_colors_support( $block_type, $block_attributes ) {
$classes = array();
$styles = array();
// Text Colors.
// Text colors.
// Check support for text colors.
if ( $has_text_colors_support ) {
$has_named_text_color = array_key_exists( 'textColor', $block_attributes );
@ -106,7 +106,7 @@ function wp_apply_colors_support( $block_type, $block_attributes ) {
}
}
// Link Colors.
// Link colors.
if ( $has_link_colors_support ) {
$has_link_color = isset( $block_attributes['style']['color']['link'] );
// Apply required class and style.
@ -124,7 +124,7 @@ function wp_apply_colors_support( $block_type, $block_attributes ) {
}
}
// Background Colors.
// Background colors.
if ( $has_background_colors_support ) {
$has_named_background_color = array_key_exists( 'backgroundColor', $block_attributes );
$has_custom_background_color = isset( $block_attributes['style']['color']['background'] );

View File

@ -2,9 +2,7 @@
"apiVersion": 2,
"name": "core/button",
"category": "design",
"parent": [
"core/buttons"
],
"parent": [ "core/buttons" ],
"attributes": {
"url": {
"type": "string",
@ -38,12 +36,6 @@
"placeholder": {
"type": "string"
},
"borderRadius": {
"type": "number"
},
"style": {
"type": "object"
},
"backgroundColor": {
"type": "string"
},
@ -65,7 +57,13 @@
"__experimentalSkipSerialization": true,
"gradients": true
},
"fontSize": true,
"reusable": false,
"__experimentalBorder": {
"radius": true,
"__experimentalSkipSerialization": true
},
"__experimentalFontFamily": true,
"__experimentalSelector": ".wp-block-button__link"
},
"editorStyle": "wp-block-button-editor",

View File

@ -2,9 +2,7 @@
"apiVersion": 2,
"name": "core/column",
"category": "text",
"parent": [
"core/columns"
],
"parent": [ "core/columns" ],
"attributes": {
"verticalAlignment": {
"type": "string"

View File

@ -9,10 +9,7 @@
},
"supports": {
"anchor": true,
"align": [
"wide",
"full"
],
"align": [ "wide", "full" ],
"html": false,
"color": {
"gradients": true,

View File

@ -0,0 +1,63 @@
{
"apiVersion": 2,
"name": "core/cover",
"category": "media",
"attributes": {
"url": {
"type": "string"
},
"id": {
"type": "number"
},
"hasParallax": {
"type": "boolean",
"default": false
},
"isRepeated": {
"type": "boolean",
"default": false
},
"dimRatio": {
"type": "number",
"default": 50
},
"overlayColor": {
"type": "string"
},
"customOverlayColor": {
"type": "string"
},
"backgroundType": {
"type": "string",
"default": "image"
},
"focalPoint": {
"type": "object"
},
"minHeight": {
"type": "number"
},
"minHeightUnit": {
"type": "string"
},
"gradient": {
"type": "string"
},
"customGradient": {
"type": "string"
},
"contentPosition": {
"type": "string"
}
},
"supports": {
"anchor": true,
"align": true,
"html": false,
"spacing": {
"padding": true
}
},
"editorStyle": "wp-block-cover-editor",
"style": "wp-block-cover"
}

View File

@ -0,0 +1,38 @@
<?php
/**
* Server-side rendering of the `core/file` block.
*
* @package WordPress
*/
/**
* When the `core/file` block is rendering, check if we need to enqueue the `'wp-block-library-file` script.
*
* @param array $attributes The block attributes.
* @param array $content The block content.
*
* @return string Returns the block content.
*/
function render_block_core_file( $attributes, $content ) {
if ( ! empty( $attributes['displayPreview'] ) ) {
// Check if it's already enqueued, so we don't add the inline script multiple times.
if ( ! wp_script_is( 'wp-block-library-file' ) ) {
wp_enqueue_script( 'wp-block-library-file', plugins_url( 'file/frontend.js', __FILE__ ) );
}
}
return $content;
}
/**
* Registers the `core/file` block on server.
*/
function register_block_core_file() {
register_block_type_from_metadata(
__DIR__ . '/file',
array(
'render_callback' => 'render_block_core_file',
)
);
}
add_action( 'init', 'register_block_core_file' );

View File

@ -34,6 +34,13 @@
"type": "string",
"source": "html",
"selector": "a[download]"
},
"displayPreview": {
"type": "boolean"
},
"previewHeight": {
"type": "number",
"default": 600
}
},
"supports": {

View File

@ -10,7 +10,8 @@
"type": "string",
"source": "html",
"selector": "h1,h2,h3,h4,h5,h6",
"default": ""
"default": "",
"__experimentalRole": "content"
},
"level": {
"type": "number",

View File

@ -10,6 +10,7 @@ require ABSPATH . WPINC . '/blocks/archives.php';
require ABSPATH . WPINC . '/blocks/block.php';
require ABSPATH . WPINC . '/blocks/calendar.php';
require ABSPATH . WPINC . '/blocks/categories.php';
require ABSPATH . WPINC . '/blocks/file.php';
require ABSPATH . WPINC . '/blocks/latest-comments.php';
require ABSPATH . WPINC . '/blocks/latest-posts.php';
require ABSPATH . WPINC . '/blocks/rss.php';
@ -33,7 +34,6 @@ function register_core_block_types_from_metadata() {
'column',
'columns',
'embed',
'file',
'freeform',
'gallery',
'group',

View File

@ -58,11 +58,7 @@
},
"featuredImageAlign": {
"type": "string",
"enum": [
"left",
"center",
"right"
]
"enum": [ "left", "center", "right" ]
},
"featuredImageSizeSlug": {
"type": "string",

View File

@ -5,7 +5,8 @@
"attributes": {
"ordered": {
"type": "boolean",
"default": false
"default": false,
"__experimentalRole": "content"
},
"values": {
"type": "string",
@ -13,7 +14,8 @@
"selector": "ol,ul",
"multiline": "li",
"__unstableMultilineWrapperTags": [ "ol", "ul" ],
"default": ""
"default": "",
"__experimentalRole": "content"
},
"type": {
"type": "string"
@ -23,6 +25,9 @@
},
"reversed": {
"type": "boolean"
},
"placeholder": {
"type": "string"
}
},
"supports": {

View File

@ -10,7 +10,8 @@
"type": "string",
"source": "html",
"selector": "p",
"default": ""
"default": "",
"__experimentalRole": "content"
},
"dropCap": {
"type": "boolean",
@ -21,10 +22,7 @@
},
"direction": {
"type": "string",
"enum": [
"ltr",
"rtl"
]
"enum": [ "ltr", "rtl" ]
}
},
"supports": {

View File

@ -8,7 +8,8 @@
"source": "html",
"selector": "pre",
"default": "",
"__unstablePreserveWhiteSpace": true
"__unstablePreserveWhiteSpace": true,
"__experimentalRole": "content"
}
},
"supports": {

View File

@ -7,13 +7,15 @@
"type": "string",
"source": "html",
"selector": "blockquote",
"multiline": "p"
"multiline": "p",
"__experimentalRole": "content"
},
"citation": {
"type": "string",
"source": "html",
"selector": "cite",
"default": ""
"default": "",
"__experimentalRole": "content"
},
"mainColor": {
"type": "string"
@ -30,12 +32,7 @@
},
"supports": {
"anchor": true,
"align": [
"left",
"right",
"wide",
"full"
]
"align": [ "left", "right", "wide", "full" ]
},
"editorStyle": "wp-block-pullquote-editor",
"style": "wp-block-pullquote"

View File

@ -8,13 +8,15 @@
"source": "html",
"selector": "blockquote",
"multiline": "p",
"default": ""
"default": "",
"__experimentalRole": "content"
},
"citation": {
"type": "string",
"source": "html",
"selector": "cite",
"default": ""
"default": "",
"__experimentalRole": "content"
},
"align": {
"type": "string"

View File

@ -4,7 +4,8 @@
"category": "widgets",
"attributes": {
"label": {
"type": "string"
"type": "string",
"__experimentalRole": "content"
},
"showLabel": {
"type": "boolean",
@ -12,7 +13,8 @@
},
"placeholder": {
"type": "string",
"default": ""
"default": "",
"__experimentalRole": "content"
},
"width": {
"type": "number"
@ -21,7 +23,8 @@
"type": "string"
},
"buttonText": {
"type": "string"
"type": "string",
"__experimentalRole": "content"
},
"buttonPosition": {
"type": "string",

View File

@ -12,7 +12,7 @@
},
"supports": {
"anchor": true,
"align": ["center","wide","full"]
"align": [ "center", "wide", "full" ]
},
"editorStyle": "wp-block-separator-editor",
"style": "wp-block-separator"

View File

@ -8,9 +8,9 @@
/**
* Renders the `core/social-link` block on server.
*
* @param Array $attributes The block attributes.
* @param String $content InnerBlocks content of the Block.
* @param WPBlock $block Block object.
* @param Array $attributes The block attributes.
* @param String $content InnerBlocks content of the Block.
* @param WP_Block $block Block object.
*
* @return string Rendered HTML of the referenced block.
*/

View File

@ -2,9 +2,7 @@
"apiVersion": 2,
"name": "core/social-link",
"category": "widgets",
"parent": [
"core/social-links"
],
"parent": [ "core/social-links" ],
"attributes": {
"url": {
"type": "string"

View File

@ -35,11 +35,7 @@
"iconBackgroundColorValue": "iconBackgroundColorValue"
},
"supports": {
"align": [
"left",
"center",
"right"
],
"align": [ "left", "center", "right" ],
"anchor": true
},
"editorStyle": "wp-block-social-links-editor",

View File

@ -11,9 +11,7 @@
"type": "number"
}
},
"usesContext": [
"orientation"
],
"usesContext": [ "orientation" ],
"supports": {
"anchor": true
},

View File

@ -14,10 +14,7 @@
"source": "html"
}
},
"default": [
{},
{}
]
"default": [ {}, {} ]
},
"columns": {
"type": "number",

View File

@ -8,7 +8,8 @@
"source": "html",
"selector": "pre",
"default": "",
"__unstablePreserveWhiteSpace": true
"__unstablePreserveWhiteSpace": true,
"__experimentalRole": "content"
},
"textAlign": {
"type": "string"
@ -16,6 +17,10 @@
},
"supports": {
"anchor": true,
"color": {
"gradients": true,
"link": true
},
"__experimentalFontFamily": true,
"fontSize": true,
"spacing": {

View File

@ -306,6 +306,7 @@ function _unhook_block_registration() {
remove_action( 'init', 'register_block_core_block' );
remove_action( 'init', 'register_block_core_calendar' );
remove_action( 'init', 'register_block_core_categories' );
remove_action( 'init', 'register_block_core_file' );
remove_action( 'init', 'register_block_core_latest_comments' );
remove_action( 'init', 'register_block_core_latest_posts' );
remove_action( 'init', 'register_block_core_rss' );

View File

@ -109,6 +109,7 @@ module.exports = function( env = { environment: 'production', watch: false, buil
'block',
'calendar',
'categories',
'file',
'latest-comments',
'latest-posts',
'rss',
@ -124,8 +125,8 @@ module.exports = function( env = { environment: 'production', watch: false, buil
'code',
'column',
'columns',
'cover',
'embed',
'file',
'freeform',
'gallery',
'group',