Editor: Update WordPress packages for 6.0 RC 4

[53419] Editor: Fix opinionated block styles loading in editor

[53420] Editor: Update WordPress packages for 6.0 RC 4

[53421] Docs: Add missing documentation for fallback_gap_value param

Props SergeyBiryukov, zieladam, jffng.
Merges [53419], [53420] and [53421] to the 6.0 branch.
Fixes #55567.





git-svn-id: https://develop.svn.wordpress.org/branches/6.0@53422 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Greg Ziółkowski 2022-05-20 15:49:09 +00:00
parent c43931c060
commit 47143c7c27
7 changed files with 337 additions and 299 deletions

563
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -81,28 +81,28 @@
"@wordpress/api-fetch": "6.3.1",
"@wordpress/autop": "3.6.1",
"@wordpress/blob": "3.6.1",
"@wordpress/block-directory": "3.4.10",
"@wordpress/block-editor": "8.5.7",
"@wordpress/block-library": "7.3.10",
"@wordpress/block-directory": "3.4.11",
"@wordpress/block-editor": "8.5.8",
"@wordpress/block-library": "7.3.11",
"@wordpress/block-serialization-default-parser": "4.6.1",
"@wordpress/blocks": "11.5.3",
"@wordpress/components": "19.8.4",
"@wordpress/compose": "5.4.1",
"@wordpress/core-data": "4.4.5",
"@wordpress/customize-widgets": "3.3.10",
"@wordpress/customize-widgets": "3.3.11",
"@wordpress/data": "6.6.1",
"@wordpress/data-controls": "2.6.1",
"@wordpress/date": "4.6.1",
"@wordpress/deprecated": "3.6.1",
"@wordpress/dom": "3.6.1",
"@wordpress/dom-ready": "3.6.1",
"@wordpress/edit-post": "6.3.10",
"@wordpress/edit-site": "4.3.10",
"@wordpress/edit-widgets": "4.3.10",
"@wordpress/editor": "12.5.7",
"@wordpress/edit-post": "6.3.11",
"@wordpress/edit-site": "4.3.11",
"@wordpress/edit-widgets": "4.3.11",
"@wordpress/editor": "12.5.8",
"@wordpress/element": "4.4.1",
"@wordpress/escape-html": "2.6.1",
"@wordpress/format-library": "3.4.7",
"@wordpress/format-library": "3.4.8",
"@wordpress/hooks": "3.6.1",
"@wordpress/html-entities": "3.6.1",
"@wordpress/i18n": "4.6.1",
@ -120,7 +120,7 @@
"@wordpress/primitives": "3.4.1",
"@wordpress/priority-queue": "2.6.1",
"@wordpress/redux-routine": "4.6.1",
"@wordpress/reusable-blocks": "3.4.7",
"@wordpress/reusable-blocks": "3.4.8",
"@wordpress/rich-text": "5.4.2",
"@wordpress/server-side-render": "3.4.5",
"@wordpress/shortcode": "3.6.1",
@ -129,7 +129,7 @@
"@wordpress/url": "3.7.1",
"@wordpress/viewport": "4.4.1",
"@wordpress/warning": "2.6.1",
"@wordpress/widgets": "2.4.7",
"@wordpress/widgets": "2.4.8",
"@wordpress/wordcount": "3.6.1",
"backbone": "1.4.1",
"clipboard": "2.0.10",

File diff suppressed because one or more lines are too long

View File

@ -309,10 +309,13 @@ function _wp_get_iframed_editor_assets() {
$style_handles = array(
'wp-block-editor',
'wp-block-library',
'wp-block-library-theme',
'wp-edit-blocks',
);
if ( current_theme_supports( 'wp-block-styles' ) ) {
$style_handles[] = 'wp-block-library-theme';
}
if ( 'widgets.php' === $pagenow || 'customize.php' === $pagenow ) {
$style_handles[] = 'wp-widgets';
$style_handles[] = 'wp-edit-widgets';

View File

@ -41,9 +41,10 @@ function wp_register_layout_support( $block_type ) {
* @param boolean $has_block_gap_support Whether the theme has support for the block gap.
* @param string $gap_value The block gap value to apply.
* @param boolean $should_skip_gap_serialization Whether to skip applying the user-defined value set in the editor.
* @param string $fallback_gap_value The custom fallback value for block gap.
* @return string CSS style.
*/
function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false ) {
function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false, $fallback_gap_value = '0.5em' ) {
$layout_type = isset( $layout['type'] ) ? $layout['type'] : 'default';
$style = '';
@ -102,14 +103,14 @@ function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false
$style .= 'display: flex;';
if ( $has_block_gap_support ) {
if ( is_array( $gap_value ) ) {
$gap_row = isset( $gap_value['top'] ) ? $gap_value['top'] : '0.5em';
$gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : '0.5em';
$gap_row = isset( $gap_value['top'] ) ? $gap_value['top'] : $fallback_gap_value;
$gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : $fallback_gap_value;
$gap_value = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column;
}
$gap_style = $gap_value && ! $should_skip_gap_serialization ? $gap_value : 'var( --wp--style--block-gap, 0.5em )';
$gap_style = $gap_value && ! $should_skip_gap_serialization ? $gap_value : "var( --wp--style--block-gap, $fallback_gap_value )";
$style .= "gap: $gap_style;";
} else {
$style .= 'gap: 0.5em;';
$style .= "gap: $fallback_gap_value;";
}
$style .= "flex-wrap: $flex_wrap;";
@ -182,10 +183,12 @@ function wp_render_layout_support_flag( $block_content, $block ) {
$gap_value = $gap_value && preg_match( '%[\\\(&=}]|/\*%', $gap_value ) ? null : $gap_value;
}
$fallback_gap_value = _wp_array_get( $block_type->supports, array( 'spacing', 'blockGap', '__experimentalDefault' ), '0.5em' );
// If a block's block.json skips serialization for spacing or spacing.blockGap,
// don't apply the user-defined value to the styles.
$should_skip_gap_serialization = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'blockGap' );
$style = wp_get_layout_style( ".$class_name", $used_layout, $has_block_gap_support, $gap_value, $should_skip_gap_serialization );
$style = wp_get_layout_style( ".$class_name", $used_layout, $has_block_gap_support, $gap_value, $should_skip_gap_serialization, $fallback_gap_value );
// This assumes the hook only applies to blocks with a single wrapper.
// I think this is a reasonable limitation for that particular hook.
$content = preg_replace(

View File

@ -28,7 +28,9 @@
}
},
"spacing": {
"blockGap": true,
"blockGap": {
"__experimentalDefault": "2em"
},
"margin": [ "top", "bottom" ],
"padding": true,
"__experimentalDefaultControls": {

View File

@ -48,7 +48,14 @@ function block_core_gallery_render( $attributes, $content ) {
// Skip if gap value contains unsupported characters.
// Regex for CSS value borrowed from `safecss_filter_attr`, and used here
// because we only want to match against the value, not the CSS attribute.
$gap = preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap;
if ( is_array( $gap ) ) {
foreach ( $gap as $key => $value ) {
$gap[ $key ] = $value && preg_match( '%[\\\(&=}]|/\*%', $value ) ? null : $value;
}
} else {
$gap = $gap && preg_match( '%[\\\(&=}]|/\*%', $gap ) ? null : $gap;
}
$class = wp_unique_id( 'wp-block-gallery-' );
$content = preg_replace(
'/' . preg_quote( 'class="', '/' ) . '/',
@ -56,10 +63,22 @@ function block_core_gallery_render( $attributes, $content ) {
$content,
1
);
// --gallery-block--gutter-size is deprecated. --wp--style--gallery-gap-default should be used by themes that want to set a default
// gap on the gallery.
$gap_value = $gap ? $gap : 'var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )';
$style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_value . '; gap: ' . $gap_value . '}';
$fallback_gap = 'var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) )';
$gap_value = $gap ? $gap : $fallback_gap;
$gap_column = $gap_value;
if ( is_array( $gap_value ) ) {
$gap_row = isset( $gap_value['top'] ) ? $gap_value['top'] : $fallback_gap;
$gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : $fallback_gap;
$gap_value = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column;
}
// Set the CSS variable to the column value, and the `gap` property to the combined gap value.
$style = '.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}';
// Ideally styles should be loaded in the head, but blocks may be parsed
// after that, so loading in the footer for now.
// See https://core.trac.wordpress.org/ticket/53494.