Skip to content

Commit

Permalink
Merge branch 'trunk' of github.com:WordPress/gutenberg into refactor/…
Browse files Browse the repository at this point in the history
…block-list-uses-hooks
  • Loading branch information
dcalhoun committed May 8, 2023
2 parents cddfb31 + f4730d7 commit af77614
Show file tree
Hide file tree
Showing 239 changed files with 6,282 additions and 2,820 deletions.
8 changes: 6 additions & 2 deletions bin/packages/build-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ async function buildCSS( file ) {
'animations',
'z-index',
]
// Editor styles should be excluded from the default CSS vars output.
// Editor and component styles should be excluded from the default CSS vars output.
.concat(
file.includes( 'common.scss' ) || ! file.includes( 'block-library' )
file.includes( 'common.scss' ) ||
! (
file.includes( 'block-library' ) ||
file.includes( 'components' )
)
? [ 'default-custom-properties' ]
: []
)
Expand Down
6 changes: 6 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1577,6 +1577,12 @@
"markdown_source": "../packages/dom/README.md",
"parent": "packages"
},
{
"title": "@wordpress/e2e-test-utils-playwright",
"slug": "packages-e2e-test-utils-playwright",
"markdown_source": "../packages/e2e-test-utils-playwright/README.md",
"parent": "packages"
},
{
"title": "@wordpress/e2e-test-utils",
"slug": "packages-e2e-test-utils",
Expand Down
4 changes: 2 additions & 2 deletions docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ Displays a title with the number of comments ([Source](https://github.com/WordPr

## Cover

Add an image or video with a text overlay — great for headers. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/cover))
Add an image or video with a text overlay. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/cover))

- **Name:** core/cover
- **Category:** media
Expand Down Expand Up @@ -383,7 +383,7 @@ Show login & logout links. ([Source](https://github.com/WordPress/gutenberg/tree

- **Name:** core/loginout
- **Category:** theme
- **Supports:** anchor, className, typography (~~fontSize~~)
- **Supports:** anchor, className, typography (fontSize, lineHeight)
- **Attributes:** displayLoginAsForm, redirectToCurrent

## Media & Text
Expand Down
36 changes: 36 additions & 0 deletions docs/reference-guides/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ _Returns_

- `any`: The current theme.

### getCurrentThemeGlobalStylesRevisions

Returns the revisions of the current global styles theme.

_Parameters_

- _state_ `State`: Data state.

_Returns_

- `Object | null`: The current global styles.

### getCurrentUser

Returns the current user.
Expand Down Expand Up @@ -317,6 +329,18 @@ _Returns_

- `any`: The entity record's save error.

### getNavigationFallbackId

Retrieve the fallback Navigation.

_Parameters_

- _state_ `State`: Data state.

_Returns_

- `EntityRecordKey | undefined`: The ID for the fallback Navigation post.

### getRawEntityRecord

Returns the entity's record object by key, with its attributes mapped to their raw values.
Expand Down Expand Up @@ -607,6 +631,18 @@ _Returns_

- `Object`: Action object.

### receiveNavigationFallbackId

Returns an action object signalling that the fallback Navigation Menu id has been received.

_Parameters_

- _fallbackId_ `integer`: the id of the fallback Navigation Menu

_Returns_

- `Object`: Action object.

### receiveThemeSupports

> **Deprecated** since WP 5.9, this is not useful anymore, use the selector direclty.
Expand Down
10 changes: 6 additions & 4 deletions lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,11 @@ function gutenberg_get_typography_value_and_unit( $raw_value, $options = array()
return null;
}

// Converts numeric values to pixel values by default.
if ( empty( $raw_value ) ) {
return null;
}

// Converts numbers to pixel values by default.
// Converts numeric values to pixel values by default.
if ( is_numeric( $raw_value ) ) {
$raw_value = $raw_value . 'px';
}
Expand Down Expand Up @@ -429,7 +428,10 @@ function gutenberg_get_typography_font_size_value( $preset, $should_use_fluid_ty
}

// Checks if fluid font sizes are activated.
$typography_settings = gutenberg_get_global_settings( array( 'typography' ) );
$global_settings = gutenberg_get_global_settings();
$typography_settings = isset( $global_settings['typography'] ) ? $global_settings['typography'] : array();
$layout_settings = isset( $global_settings['layout'] ) ? $global_settings['layout'] : array();

$should_use_fluid_typography
= isset( $typography_settings['fluid'] ) &&
( true === $typography_settings['fluid'] || is_array( $typography_settings['fluid'] ) ) ?
Expand All @@ -443,7 +445,7 @@ function gutenberg_get_typography_font_size_value( $preset, $should_use_fluid_ty
$fluid_settings = isset( $typography_settings['fluid'] ) && is_array( $typography_settings['fluid'] ) ? $typography_settings['fluid'] : array();

// Defaults.
$default_maximum_viewport_width = '1600px';
$default_maximum_viewport_width = isset( $layout_settings['wideSize'] ) ? $layout_settings['wideSize'] : '1600px';
$default_minimum_viewport_width = '320px';
$default_minimum_font_size_factor_max = 0.75;
$default_minimum_font_size_factor_min = 0.25;
Expand Down
33 changes: 24 additions & 9 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ function gutenberg_reregister_core_block_types() {
$block_folders = $details['block_folders'];
$block_names = $details['block_names'];

$registry = WP_Block_Type_Registry::get_instance();

foreach ( $block_folders as $folder_name ) {
$block_json_file = $blocks_dir . $folder_name . '/block.json';

Expand All @@ -150,10 +148,7 @@ function gutenberg_reregister_core_block_types() {
continue;
}

if ( $registry->is_registered( $metadata['name'] ) ) {
$registry->unregister( $metadata['name'] );
}

gutenberg_deregister_core_block_and_assets( $metadata['name'] );
gutenberg_register_core_block_assets( $folder_name );
register_block_type_from_metadata( $block_json_file );
}
Expand All @@ -165,9 +160,7 @@ function gutenberg_reregister_core_block_types() {

$sub_block_names_normalized = is_string( $sub_block_names ) ? array( $sub_block_names ) : $sub_block_names;
foreach ( $sub_block_names_normalized as $block_name ) {
if ( $registry->is_registered( $block_name ) ) {
$registry->unregister( $block_name );
}
gutenberg_deregister_core_block_and_assets( $block_name );
gutenberg_register_core_block_assets( $block_name );
}

Expand All @@ -178,6 +171,28 @@ function gutenberg_reregister_core_block_types() {

add_action( 'init', 'gutenberg_reregister_core_block_types' );

/**
* Deregisters the existing core block type and its assets.
*
* @param string $block_name The name of the block.
*
* @return void
*/
function gutenberg_deregister_core_block_and_assets( $block_name ) {
$registry = WP_Block_Type_Registry::get_instance();
if ( $registry->is_registered( $block_name ) ) {
$block_type = $registry->get_registered( $block_name );
if ( ! empty( $block_type->view_script_handles ) ) {
foreach ( $block_type->view_script_handles as $view_script_handle ) {
if ( str_starts_with( $view_script_handle, 'wp-block-' ) ) {
wp_deregister_script( $view_script_handle );
}
}
}
$registry->unregister( $block_name );
}
}

/**
* Registers block styles for a core block.
*
Expand Down
12 changes: 2 additions & 10 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,8 @@ function gutenberg_override_script( $scripts, $handle, $src, $deps = array(), $v
$scripts->add( $handle, $src, $deps, $ver, ( $in_footer ? 1 : null ) );
}

/*
* `WP_Dependencies::set_translations` will fall over on itself if setting
* translations on the `wp-i18n` handle, since it internally adds `wp-i18n`
* as a dependency of itself, exhausting memory. The same applies for the
* polyfill and hooks scripts, which are dependencies _of_ `wp-i18n`.
*
* See: https://core.trac.wordpress.org/ticket/46089
*/
if ( ! in_array( $handle, array( 'wp-i18n', 'wp-polyfill', 'wp-hooks' ), true ) ) {
$scripts->set_translations( $handle, 'default' );
if ( in_array( 'wp-i18n', $deps, true ) ) {
$scripts->set_translations( $handle );
}

/*
Expand Down
Loading

0 comments on commit af77614

Please sign in to comment.