diff --git a/docs/contributors/code/coding-guidelines.md b/docs/contributors/code/coding-guidelines.md index 12c3ad96cb85f..9c20e73524ec4 100644 --- a/docs/contributors/code/coding-guidelines.md +++ b/docs/contributors/code/coding-guidelines.md @@ -162,7 +162,7 @@ do so by opting-in to `@wordpress/private-apis`: import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/block-editor' // Name of the package calling __dangerousOptInToUnstableAPIsOnlyForCoreModules, // (not the name of the package whose APIs you want to access) ); diff --git a/package-lock.json b/package-lock.json index a04f17460b3d9..d365295a47705 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57755,8 +57755,7 @@ "@wordpress/url": "file:../url" }, "engines": { - "node": ">=16.0.0", - "npm": ">=8 <9" + "node": ">=16.0.0" }, "peerDependencies": { "react": "^18.0.0", diff --git a/packages/block-editor/src/hooks/utils.js b/packages/block-editor/src/hooks/utils.js index f81fc118ea84b..8e0d422c5fbec 100644 --- a/packages/block-editor/src/hooks/utils.js +++ b/packages/block-editor/src/hooks/utils.js @@ -279,6 +279,8 @@ export function useBlockSettings( name, parentLayout ) { isBackgroundEnabled, isLinkEnabled, isTextEnabled, + isHeadingEnabled, + isButtonEnabled, ] ); return useSettingsForBlockElement( rawSettings, name ); diff --git a/packages/block-editor/src/lock-unlock.js b/packages/block-editor/src/lock-unlock.js index 019821d284b36..433a61a12aec0 100644 --- a/packages/block-editor/src/lock-unlock.js +++ b/packages/block-editor/src/lock-unlock.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/block-editor' ); diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index d49a8f7cd0578..1f602c4380e88 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -377,6 +377,8 @@ export default function Image( { const lightboxChecked = !! lightbox?.enabled || ( ! lightbox && !! lightboxSetting?.enabled ); + const lightboxToggleDisabled = linkDestination !== 'none'; + const dimensionsControl = ( ) } diff --git a/packages/block-library/src/image/index.php b/packages/block-library/src/image/index.php index e1f71964622c0..87e17a4c136b4 100644 --- a/packages/block-library/src/image/index.php +++ b/packages/block-library/src/image/index.php @@ -16,11 +16,13 @@ * @return string The block content with the data-id attribute added. */ function render_block_core_image( $attributes, $content, $block ) { + if ( false === stripos( $content, 'next_tag( 'img' ); - if ( $processor->get_attribute( 'src' ) === null ) { + if ( ! $processor->next_tag( 'img' ) || null === $processor->get_attribute( 'src' ) ) { return ''; } @@ -32,45 +34,47 @@ function render_block_core_image( $attributes, $content, $block ) { $processor->set_attribute( 'data-id', $attributes['data-id'] ); } - $lightbox_enabled = false; $link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none'; $lightbox_settings = block_core_image_get_lightbox_settings( $block->parsed_block ); - // If the lightbox is enabled and the image is not linked, flag the lightbox to be rendered. - if ( isset( $lightbox_settings ) && 'none' === $link_destination ) { - - if ( isset( $lightbox_settings['enabled'] ) && true === $lightbox_settings['enabled'] ) { - $lightbox_enabled = true; - } - } + $view_js_file_handle = 'wp-block-image-view'; + $script_handles = $block->block_type->view_script_handles; - // If at least one block in the page has the lightbox, mark the block type as interactive. - if ( $lightbox_enabled ) { + /* + * If the lightbox is enabled and the image is not linked, add the filter + * and the JavaScript view file. + */ + if ( + isset( $lightbox_settings ) && + 'none' === $link_destination && + isset( $lightbox_settings['enabled'] ) && + true === $lightbox_settings['enabled'] + ) { $block->block_type->supports['interactivity'] = true; - } - - // Determine whether the view script should be enqueued or not. - $view_js_file = 'wp-block-image-view'; - if ( ! wp_script_is( $view_js_file ) ) { - $script_handles = $block->block_type->view_script_handles; - // If the script is not needed, and it is still in the `view_script_handles`, remove it. - if ( ! $lightbox_enabled && in_array( $view_js_file, $script_handles, true ) ) { - $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) ); - } - // If the script is needed, but it was previously removed, add it again. - if ( $lightbox_enabled && ! in_array( $view_js_file, $script_handles, true ) ) { - $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) ); + if ( ! in_array( $view_js_file_handle, $script_handles, true ) ) { + $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file_handle ) ); } - } - if ( $lightbox_enabled ) { - // This render needs to happen in a filter with priority 15 to ensure that it - // runs after the duotone filter and that duotone styles are applied to the image - // in the lightbox. We also need to ensure that the lightbox works with any plugins - // that might use filters as well. We can consider removing this in the future if the - // way the blocks are rendered changes, or if a new kind of filter is introduced. + /* + * This render needs to happen in a filter with priority 15 to ensure + * that it runs after the duotone filter and that duotone styles are + * applied to the image in the lightbox. We also need to ensure that the + * lightbox works with any plugins that might use filters as well. We + * can consider removing this in the future if the way the blocks are + * rendered changes, or if a new kind of filter is introduced. + */ add_filter( 'render_block_core/image', 'block_core_image_render_lightbox', 15, 2 ); + } else { + /* + * Remove the filter and the JavaScript view file if previously added by + * other Image blocks. + */ + remove_filter( 'render_block_core/image', 'block_core_image_render_lightbox', 15 ); + // If the script is not needed, and it is still in the `view_script_handles`, remove it. + if ( in_array( $view_js_file_handle, $script_handles, true ) ) { + $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file_handle ) ); + } } return $processor->get_updated_html(); @@ -123,11 +127,28 @@ function block_core_image_get_lightbox_settings( $block ) { * @return string Filtered block content. */ function block_core_image_render_lightbox( $block_content, $block ) { + /* + * If it's not possible that an IMG element exists then return the given + * block content as-is. It may be that there's no actual image in the block + * or it could be that another plugin already modified this HTML. + */ + if ( false === stripos( $block_content, 'next_tag( 'img' ); + /* + * If there's definitely no IMG element in the block then return the given + * block content as-is. There's nothing that this code can knowingly modify + * to add the lightbox behavior. + */ + if ( ! $processor->next_tag( 'img' ) ) { + return $block_content; + } + $alt_attribute = $processor->get_attribute( 'alt' ); // An empty alt attribute `alt=""` is valid for decorative images. @@ -310,8 +331,6 @@ function block_core_image_render_lightbox( $block_content, $block ) { * @since 6.4.0 * * @global WP_Scripts $wp_scripts - * - * @return void */ function block_core_image_ensure_interactivity_dependency() { global $wp_scripts; @@ -327,8 +346,6 @@ function block_core_image_ensure_interactivity_dependency() { /** * Registers the `core/image` block on server. - * - * @return void */ function register_block_core_image() { register_block_type_from_metadata( diff --git a/packages/block-library/src/list-item/hooks/use-merge.js b/packages/block-library/src/list-item/hooks/use-merge.js index 6b456a2a742bd..cda1f0c02d3a8 100644 --- a/packages/block-library/src/list-item/hooks/use-merge.js +++ b/packages/block-library/src/list-item/hooks/use-merge.js @@ -76,6 +76,24 @@ export default function useMerge( clientId, onMerge ) { } return ( forward ) => { + function mergeWithNested( clientIdA, clientIdB ) { + registry.batch( () => { + // When merging a sub list item with a higher next list item, we + // also need to move any nested list items. Check if there's a + // listed list, and append its nested list items to the current + // list. + const [ nestedListClientId ] = getBlockOrder( clientIdB ); + if ( nestedListClientId ) { + moveBlocksToPosition( + getBlockOrder( nestedListClientId ), + nestedListClientId, + getBlockRootClientId( clientIdA ) + ); + } + mergeBlocks( clientIdA, clientIdB ); + } ); + } + if ( forward ) { const nextBlockClientId = getNextId( clientId ); @@ -87,14 +105,7 @@ export default function useMerge( clientId, onMerge ) { if ( getParentListItemId( nextBlockClientId ) ) { outdentListItem( nextBlockClientId ); } else { - registry.batch( () => { - moveBlocksToPosition( - getBlockOrder( nextBlockClientId ), - nextBlockClientId, - getPreviousBlockClientId( nextBlockClientId ) - ); - mergeBlocks( clientId, nextBlockClientId ); - } ); + mergeWithNested( clientId, nextBlockClientId ); } } else { // Merging is only done from the top level. For lowel levels, the @@ -104,21 +115,7 @@ export default function useMerge( clientId, onMerge ) { outdentListItem( clientId ); } else if ( previousBlockClientId ) { const trailingId = getTrailingId( previousBlockClientId ); - registry.batch( () => { - // When merging a list item with a previous trailing list - // item, we also need to move any nested list items. First, - // check if there's a listed list. If there's a nested list, - // append its nested list items to the trailing list. - const [ nestedListClientId ] = getBlockOrder( clientId ); - if ( nestedListClientId ) { - moveBlocksToPosition( - getBlockOrder( nestedListClientId ), - nestedListClientId, - getBlockRootClientId( trailingId ) - ); - } - mergeBlocks( trailingId, clientId ); - } ); + mergeWithNested( trailingId, clientId ); } else { onMerge( forward ); } diff --git a/packages/block-library/src/lock-unlock.js b/packages/block-library/src/lock-unlock.js index 3fef0820721be..3c18e76b798cd 100644 --- a/packages/block-library/src/lock-unlock.js +++ b/packages/block-library/src/lock-unlock.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/block-library' ); diff --git a/packages/block-library/src/pattern/index.php b/packages/block-library/src/pattern/index.php index fc4652a7c22e8..f05bb333bd186 100644 --- a/packages/block-library/src/pattern/index.php +++ b/packages/block-library/src/pattern/index.php @@ -7,8 +7,6 @@ /** * Registers the `core/pattern` block on the server. - * - * @return void */ function register_block_core_pattern() { register_block_type_from_metadata( @@ -46,7 +44,6 @@ function render_block_core_pattern( $attributes ) { // Backward compatibility for handling Block Hooks and injecting the theme attribute in the Gutenberg plugin. // This can be removed when the minimum supported WordPress is >= 6.4. if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && ! function_exists( 'traverse_and_serialize_blocks' ) ) { - $content = _inject_theme_attribute_in_block_template_content( $content ); $blocks = parse_blocks( $content ); $content = gutenberg_serialize_blocks( $blocks ); } diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index ed3d1cf4b847a..f00ecfe6abe1c 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -281,8 +281,6 @@ function classnames_for_block_core_search( $attributes ) { * @param array $wrapper_styles Current collection of wrapper styles. * @param array $button_styles Current collection of button styles. * @param array $input_styles Current collection of input styles. - * - * @return void */ function apply_block_core_search_border_style( $attributes, $property, $side, &$wrapper_styles, &$button_styles, &$input_styles ) { $is_button_inside = isset( $attributes['buttonPosition'] ) && 'button-inside' === $attributes['buttonPosition']; @@ -327,8 +325,6 @@ function apply_block_core_search_border_style( $attributes, $property, $side, &$ * @param array $wrapper_styles Current collection of wrapper styles. * @param array $button_styles Current collection of button styles. * @param array $input_styles Current collection of input styles. - * - * @return void */ function apply_block_core_search_border_styles( $attributes, $property, &$wrapper_styles, &$button_styles, &$input_styles ) { apply_block_core_search_border_style( $attributes, $property, null, $wrapper_styles, $button_styles, $input_styles ); diff --git a/packages/block-library/src/template-part/index.php b/packages/block-library/src/template-part/index.php index a7bd4033affc3..3ad400906945b 100644 --- a/packages/block-library/src/template-part/index.php +++ b/packages/block-library/src/template-part/index.php @@ -18,13 +18,10 @@ function render_block_core_template_part( $attributes ) { $template_part_id = null; $content = null; $area = WP_TEMPLATE_PART_AREA_UNCATEGORIZED; + $theme = isset( $attributes['theme'] ) ? $attributes['theme'] : get_stylesheet(); - if ( - isset( $attributes['slug'] ) && - isset( $attributes['theme'] ) && - get_stylesheet() === $attributes['theme'] - ) { - $template_part_id = $attributes['theme'] . '//' . $attributes['slug']; + if ( isset( $attributes['slug'] ) && get_stylesheet() === $theme ) { + $template_part_id = $theme . '//' . $attributes['slug']; $template_part_query = new WP_Query( array( 'post_type' => 'wp_template_part', @@ -34,7 +31,7 @@ function render_block_core_template_part( $attributes ) { array( 'taxonomy' => 'wp_theme', 'field' => 'name', - 'terms' => $attributes['theme'], + 'terms' => $theme, ), ), 'posts_per_page' => 1, diff --git a/packages/blocks/src/lock-unlock.js b/packages/blocks/src/lock-unlock.js index 363b51af7d233..0a98fcfb19d29 100644 --- a/packages/blocks/src/lock-unlock.js +++ b/packages/blocks/src/lock-unlock.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/blocks' ); diff --git a/packages/commands/src/lock-unlock.js b/packages/commands/src/lock-unlock.js index 0665114d842c3..e11bd687d8742 100644 --- a/packages/commands/src/lock-unlock.js +++ b/packages/commands/src/lock-unlock.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/commands' ); diff --git a/packages/components/src/private-apis.ts b/packages/components/src/private-apis.ts index 6e17abde0c627..55a3a79fd638b 100644 --- a/packages/components/src/private-apis.ts +++ b/packages/components/src/private-apis.ts @@ -27,7 +27,7 @@ import Theme from './theme'; export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/components' ); diff --git a/packages/core-commands/src/lock-unlock.js b/packages/core-commands/src/lock-unlock.js index 24973274f1897..6f0712a8069fd 100644 --- a/packages/core-commands/src/lock-unlock.js +++ b/packages/core-commands/src/lock-unlock.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/core-commands' ); diff --git a/packages/core-data/src/private-apis.js b/packages/core-data/src/private-apis.js index a5b93a25dbf77..53f0dc2dfa133 100644 --- a/packages/core-data/src/private-apis.js +++ b/packages/core-data/src/private-apis.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/core-data' ); diff --git a/packages/customize-widgets/src/lock-unlock.js b/packages/customize-widgets/src/lock-unlock.js index f428bbaac936a..01d57a2835d5d 100644 --- a/packages/customize-widgets/src/lock-unlock.js +++ b/packages/customize-widgets/src/lock-unlock.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/customize-widgets' ); diff --git a/packages/data/src/lock-unlock.js b/packages/data/src/lock-unlock.js index 5fdca775a27b8..b5b1f9cbed5a5 100644 --- a/packages/data/src/lock-unlock.js +++ b/packages/data/src/lock-unlock.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/data' ); diff --git a/packages/edit-post/src/lock-unlock.js b/packages/edit-post/src/lock-unlock.js index 172d18df7d1ba..bf65b262d9f48 100644 --- a/packages/edit-post/src/lock-unlock.js +++ b/packages/edit-post/src/lock-unlock.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/edit-post' ); diff --git a/packages/edit-site/src/lock-unlock.js b/packages/edit-site/src/lock-unlock.js index 9934484ea2347..5c335db46b9d4 100644 --- a/packages/edit-site/src/lock-unlock.js +++ b/packages/edit-site/src/lock-unlock.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/edit-site' ); diff --git a/packages/edit-widgets/src/lock-unlock.js b/packages/edit-widgets/src/lock-unlock.js index a13068520e077..003e53788068c 100644 --- a/packages/edit-widgets/src/lock-unlock.js +++ b/packages/edit-widgets/src/lock-unlock.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/edit-widgets' ); diff --git a/packages/editor/src/lock-unlock.js b/packages/editor/src/lock-unlock.js index 5a36d0cd752f4..12df6f4711b23 100644 --- a/packages/editor/src/lock-unlock.js +++ b/packages/editor/src/lock-unlock.js @@ -4,6 +4,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/editor' ); diff --git a/packages/icons/src/library/fullscreen.js b/packages/icons/src/library/fullscreen.js index 8b11ddcac7217..11bef7aebd612 100644 --- a/packages/icons/src/library/fullscreen.js +++ b/packages/icons/src/library/fullscreen.js @@ -5,7 +5,7 @@ import { SVG, Path } from '@wordpress/primitives'; const fullscreen = ( - + ); diff --git a/packages/patterns/package.json b/packages/patterns/package.json index b97e214d85af0..61d3b2703d043 100644 --- a/packages/patterns/package.json +++ b/packages/patterns/package.json @@ -19,8 +19,7 @@ "url": "https://github.com/WordPress/gutenberg/issues" }, "engines": { - "node": ">=16.0.0", - "npm": ">=8 <9" + "node": ">=16.0.0" }, "main": "build/index.js", "module": "build-module/index.js", diff --git a/packages/patterns/src/lock-unlock.js b/packages/patterns/src/lock-unlock.js index 51adc98f32cac..d727871d71439 100644 --- a/packages/patterns/src/lock-unlock.js +++ b/packages/patterns/src/lock-unlock.js @@ -4,6 +4,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/patterns' ); diff --git a/packages/private-apis/README.md b/packages/private-apis/README.md index 9faaada853200..cdc1db2180e2c 100644 --- a/packages/private-apis/README.md +++ b/packages/private-apis/README.md @@ -12,7 +12,7 @@ Every `@wordpress` package wanting to privately access or expose experimental AP import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/block-editor' // Name of the package calling __dangerousOptInToUnstableAPIsOnlyForCoreModules, // (not the name of the package whose APIs you want to access) ); @@ -22,7 +22,7 @@ Each package may only opt in once. The function name communicates that plugins a The function will throw an error if the following conditions are not met: -1. The first argument must exactly match the required consent string: `'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.'`. +1. The first argument must exactly match the required consent string: `'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.'`. 2. The second argument must be a known `@wordpress` package that hasn't yet opted into `@wordpress/private-apis` Once the opt-in is complete, the obtained `lock()` and `unlock()` utilities enable hiding `__experimental` APIs from the naked eye: diff --git a/packages/private-apis/src/implementation.js b/packages/private-apis/src/implementation.js index 4f1877bff569e..14d3048eff68b 100644 --- a/packages/private-apis/src/implementation.js +++ b/packages/private-apis/src/implementation.js @@ -51,7 +51,7 @@ const registeredPrivateApis = []; * CHANGE MAY OCCUR IN EITHER A MAJOR OR MINOR RELEASE. */ const requiredConsent = - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.'; + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.'; /** @type {boolean} */ let allowReRegistration; diff --git a/packages/private-apis/src/test/index.js b/packages/private-apis/src/test/index.js index 2e73a1a58eaa1..d91f7d3bcdafe 100644 --- a/packages/private-apis/src/test/index.js +++ b/packages/private-apis/src/test/index.js @@ -16,7 +16,7 @@ beforeEach( () => { } ); const requiredConsent = - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.'; + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.'; describe( '__dangerousOptInToUnstableAPIsOnlyForCoreModules', () => { it( 'Should require a consent string', () => { diff --git a/packages/reusable-blocks/src/lock-unlock.js b/packages/reusable-blocks/src/lock-unlock.js index c33f209c9d76a..c0bc2d1529f7d 100644 --- a/packages/reusable-blocks/src/lock-unlock.js +++ b/packages/reusable-blocks/src/lock-unlock.js @@ -4,6 +4,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; export const { unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/reusable-blocks' ); diff --git a/packages/router/src/lock-unlock.js b/packages/router/src/lock-unlock.js index d148f785fe944..d7f4e92b4a542 100644 --- a/packages/router/src/lock-unlock.js +++ b/packages/router/src/lock-unlock.js @@ -5,6 +5,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri export const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules( - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/router' ); diff --git a/test/e2e/specs/editor/blocks/list.spec.js b/test/e2e/specs/editor/blocks/list.spec.js index 9fe0ce101c5e9..8994bda55ce48 100644 --- a/test/e2e/specs/editor/blocks/list.spec.js +++ b/test/e2e/specs/editor/blocks/list.spec.js @@ -1359,11 +1359,8 @@ test.describe( 'List (@firefox)', () => { ` ); } ); - test( 'should merge two list items with nested lists', async ( { - editor, - page, - } ) => { - await editor.insertBlock( { + test.describe( 'should merge two list items with nested lists', () => { + const start = { name: 'core/list', innerBlocks: [ { @@ -1397,22 +1394,8 @@ test.describe( 'List (@firefox)', () => { ], }, ], - } ); - - // Navigate to the third item. - await page.keyboard.press( 'ArrowDown' ); - await page.keyboard.press( 'ArrowDown' ); - await page.keyboard.press( 'ArrowDown' ); - await page.keyboard.press( 'ArrowDown' ); - await page.keyboard.press( 'ArrowDown' ); - await page.keyboard.press( 'ArrowDown' ); - - await page.keyboard.press( 'Backspace' ); - - // Test caret position. - await page.keyboard.type( '‸' ); - - await expect.poll( editor.getBlocks ).toMatchObject( [ + }; + const end = [ { name: 'core/list', innerBlocks: [ @@ -1437,6 +1420,43 @@ test.describe( 'List (@firefox)', () => { }, ], }, - ] ); + ]; + + test( 'Backspace', async ( { editor, page } ) => { + await editor.insertBlock( start ); + + // Navigate to the start of the third item. + await page.keyboard.press( 'ArrowDown' ); + await page.keyboard.press( 'ArrowDown' ); + await page.keyboard.press( 'ArrowDown' ); + await page.keyboard.press( 'ArrowDown' ); + await page.keyboard.press( 'ArrowDown' ); + await page.keyboard.press( 'ArrowDown' ); + + await page.keyboard.press( 'Backspace' ); + + // Test caret position. + await page.keyboard.type( '‸' ); + + await expect.poll( editor.getBlocks ).toMatchObject( end ); + } ); + + test( 'Delete (forward)', async ( { editor, page } ) => { + await editor.insertBlock( start ); + + // Navigate to the end of the second item. + await page.keyboard.press( 'ArrowDown' ); + await page.keyboard.press( 'ArrowDown' ); + await page.keyboard.press( 'ArrowDown' ); + await page.keyboard.press( 'ArrowDown' ); + await page.keyboard.press( 'ArrowRight' ); + + await page.keyboard.press( 'Delete' ); + + // Test caret position. + await page.keyboard.type( '‸' ); + + await expect.poll( editor.getBlocks ).toMatchObject( end ); + } ); } ); } );