diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml
index c0f70070908c1..b80804b824e3c 100644
--- a/.github/workflows/unit-test.yml
+++ b/.github/workflows/unit-test.yml
@@ -135,7 +135,9 @@ jobs:
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: build-assets
- path: ./build/
+ path: |
+ ./build/
+ ./build-module/
test-php:
name: PHP ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }}${{ matrix.wordpress != '' && format( ' (WP {0}) ', matrix.wordpress ) || '' }} on ubuntu-latest
@@ -212,7 +214,6 @@ jobs:
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: build-assets
- path: ./build
- name: Docker debug information
run: |
diff --git a/backport-changelog/6.7/7360.md b/backport-changelog/6.7/7360.md
new file mode 100644
index 0000000000000..b2fb8efd624b9
--- /dev/null
+++ b/backport-changelog/6.7/7360.md
@@ -0,0 +1,3 @@
+https://github.com/WordPress/wordpress-develop/pull/7360
+
+* https://github.com/WordPress/gutenberg/pull/65460
diff --git a/lib/client-assets.php b/lib/client-assets.php
index 62e874d6b06c8..2343530e5595a 100644
--- a/lib/client-assets.php
+++ b/lib/client-assets.php
@@ -601,6 +601,56 @@ function gutenberg_register_vendor_scripts( $scripts ) {
}
add_action( 'wp_default_scripts', 'gutenberg_register_vendor_scripts' );
+/**
+ * Registers or re-registers Gutenberg Script Modules.
+ *
+ * Script modules that are registered by Core will be re-registered by Gutenberg.
+ *
+ * @since 19.3.0
+ */
+function gutenberg_default_script_modules() {
+ /*
+ * Expects multidimensional array like:
+ *
+ * 'interactivity/index.min.js' => array('dependencies' => array(…), 'version' => '…'),
+ * 'interactivity/debug.min.js' => array('dependencies' => array(…), 'version' => '…'),
+ * 'interactivity-router/index.min.js' => …
+ */
+ $assets = include gutenberg_dir_path() . '/build-module/assets.php';
+
+ foreach ( $assets as $file_name => $script_module_data ) {
+ /*
+ * Build the WordPress Script Module ID from the file name.
+ * Prepend `@wordpress/` and remove extensions and `/index` if present:
+ * - interactivity/index.min.js => @wordpress/interactivity
+ * - interactivity/debug.min.js => @wordpress/interactivity/debug
+ * - block-library/query/view.js => @wordpress/block-library/query/view
+ */
+ $script_module_id = '@wordpress/' . preg_replace( '~(?:/index)?\.min\.js$~D', '', $file_name, 1 );
+ switch ( $script_module_id ) {
+ /*
+ * Interactivity exposes two entrypoints, "/index" and "/debug".
+ * "/debug" should replalce "/index" in devlopment.
+ */
+ case '@wordpress/interactivity/debug':
+ if ( ! SCRIPT_DEBUG ) {
+ continue 2;
+ }
+ $script_module_id = '@wordpress/interactivity';
+ break;
+ case '@wordpress/interactivity':
+ if ( SCRIPT_DEBUG ) {
+ continue 2;
+ }
+ break;
+ }
+
+ $path = gutenberg_url( "build-module/{$file_name}" );
+ wp_register_script_module( $script_module_id, $path, $script_module_data['dependencies'], $script_module_data['version'] );
+ }
+}
+remove_action( 'wp_default_scripts', 'wp_default_script_modules' );
+add_action( 'wp_default_scripts', 'gutenberg_default_script_modules' );
/*
* Always remove the Core action hook while gutenberg_enqueue_stored_styles() exists to avoid styles being printed twice.
diff --git a/lib/experimental/script-modules.php b/lib/experimental/script-modules.php
index f65bc1704dd89..fe23786fc0362 100644
--- a/lib/experimental/script-modules.php
+++ b/lib/experimental/script-modules.php
@@ -239,26 +239,5 @@ function gutenberg_a11y_script_module_html() {
. '
'
. '';
}
-
-/**
- * Registers Gutenberg Script Modules.
- *
- * @since 19.3
- */
-function gutenberg_register_script_modules() {
- // When in production, use the plugin's version as the default asset version;
- // else (for development or test) default to use the current time.
- $default_version = defined( 'GUTENBERG_VERSION' ) && ! SCRIPT_DEBUG ? GUTENBERG_VERSION : time();
-
- wp_deregister_script_module( '@wordpress/a11y' );
- wp_register_script_module(
- '@wordpress/a11y',
- gutenberg_url( 'build-module/a11y/index.min.js' ),
- array(),
- $default_version
- );
-
- add_action( 'wp_footer', 'gutenberg_a11y_script_module_html' );
- add_action( 'admin_footer', 'gutenberg_a11y_script_module_html' );
-}
-add_action( 'init', 'gutenberg_register_script_modules' );
+add_action( 'wp_footer', 'gutenberg_a11y_script_module_html' );
+add_action( 'admin_footer', 'gutenberg_a11y_script_module_html' );
diff --git a/lib/interactivity-api.php b/lib/interactivity-api.php
index c00d68bc70e8e..ff68936f054a7 100644
--- a/lib/interactivity-api.php
+++ b/lib/interactivity-api.php
@@ -5,37 +5,6 @@
* @package gutenberg
*/
-/**
- * Deregisters the Core Interactivity API Modules and replace them
- * with the ones from the Gutenberg plugin.
- */
-function gutenberg_reregister_interactivity_script_modules() {
- $default_version = defined( 'GUTENBERG_VERSION' ) && ! SCRIPT_DEBUG ? GUTENBERG_VERSION : time();
- wp_deregister_script_module( '@wordpress/interactivity' );
- wp_deregister_script_module( '@wordpress/interactivity-router' );
-
- wp_register_script_module(
- '@wordpress/interactivity',
- gutenberg_url( '/build-module/' . ( SCRIPT_DEBUG ? 'interactivity/debug.min.js' : 'interactivity/index.min.js' ) ),
- array(),
- $default_version
- );
-
- wp_register_script_module(
- '@wordpress/interactivity-router',
- gutenberg_url( '/build-module/interactivity-router/index.min.js' ),
- array(
- array(
- 'id' => '@wordpress/a11y',
- 'import' => 'dynamic',
- ),
- '@wordpress/interactivity',
- ),
- $default_version
- );
-}
-add_action( 'init', 'gutenberg_reregister_interactivity_script_modules' );
-
/**
* Adds script data to the interactivity-router script module.
*
diff --git a/packages/block-editor/README.md b/packages/block-editor/README.md
index a474d1df7e56d..75d7e8879572d 100644
--- a/packages/block-editor/README.md
+++ b/packages/block-editor/README.md
@@ -1027,11 +1027,11 @@ _Parameters_
### useZoomOut
-A hook used to set the editor mode to zoomed out mode, invoking the hook sets the mode.
+A hook used to set the zoomed out view, invoking the hook sets the mode.
_Parameters_
-- _zoomOut_ `boolean`: If we should enter into zoomOut mode or not
+- _zoomOut_ `boolean`: If we should zoom out or not.
### Warning
diff --git a/packages/block-editor/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js b/packages/block-editor/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js
index d0001bd3b33c6..92c54bac9b806 100644
--- a/packages/block-editor/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js
+++ b/packages/block-editor/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js
@@ -16,14 +16,17 @@ import { unlock } from '../../../lock-unlock';
* @param {string} clientId Block client ID.
*/
export function useZoomOutModeExit( { editorMode } ) {
- const { getSettings } = useSelect( blockEditorStore );
- const { __unstableSetEditorMode } = unlock(
+ const { getSettings, isZoomOut } = unlock( useSelect( blockEditorStore ) );
+ const { __unstableSetEditorMode, resetZoomLevel } = unlock(
useDispatch( blockEditorStore )
);
return useRefEffect(
( node ) => {
- if ( editorMode !== 'zoom-out' ) {
+ // In "compose" mode.
+ const composeMode = editorMode === 'zoom-out' && isZoomOut();
+
+ if ( ! composeMode ) {
return;
}
@@ -39,6 +42,7 @@ export function useZoomOutModeExit( { editorMode } ) {
__experimentalSetIsInserterOpened( false );
}
__unstableSetEditorMode( 'edit' );
+ resetZoomLevel();
}
}
diff --git a/packages/block-editor/src/components/block-list/use-in-between-inserter.js b/packages/block-editor/src/components/block-list/use-in-between-inserter.js
index bb307816fd150..2b76804785a57 100644
--- a/packages/block-editor/src/components/block-list/use-in-between-inserter.js
+++ b/packages/block-editor/src/components/block-list/use-in-between-inserter.js
@@ -11,6 +11,7 @@ import { isRTL } from '@wordpress/i18n';
*/
import { store as blockEditorStore } from '../../store';
import { InsertionPointOpenRef } from '../block-tools/insertion-point';
+import { unlock } from '../../lock-unlock';
export function useInBetweenInserter() {
const openRef = useContext( InsertionPointOpenRef );
@@ -31,7 +32,8 @@ export function useInBetweenInserter() {
getBlockEditingMode,
getBlockName,
getBlockAttributes,
- } = useSelect( blockEditorStore );
+ getParentSectionBlock,
+ } = unlock( useSelect( blockEditorStore ) );
const { showInsertionPoint, hideInsertionPoint } =
useDispatch( blockEditorStore );
@@ -133,7 +135,8 @@ export function useInBetweenInserter() {
const clientId = element.id.slice( 'block-'.length );
if (
! clientId ||
- __unstableIsWithinBlockOverlay( clientId )
+ __unstableIsWithinBlockOverlay( clientId ) ||
+ !! getParentSectionBlock( clientId )
) {
return;
}
diff --git a/packages/block-editor/src/components/block-tools/zoom-out-toolbar.js b/packages/block-editor/src/components/block-tools/zoom-out-toolbar.js
index 560bfc6ebb58d..b8736de11481a 100644
--- a/packages/block-editor/src/components/block-tools/zoom-out-toolbar.js
+++ b/packages/block-editor/src/components/block-tools/zoom-out-toolbar.js
@@ -15,6 +15,7 @@ import BlockDraggable from '../block-draggable';
import BlockMover from '../block-mover';
import Shuffle from '../block-toolbar/shuffle';
import NavigableToolbar from '../navigable-toolbar';
+import { unlock } from '../../lock-unlock';
export default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {
const selected = useSelect(
@@ -76,8 +77,9 @@ export default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {
setIsInserterOpened,
} = selected;
- const { removeBlock, __unstableSetEditorMode } =
- useDispatch( blockEditorStore );
+ const { removeBlock, __unstableSetEditorMode, resetZoomLevel } = unlock(
+ useDispatch( blockEditorStore )
+ );
const showBlockDraggable = canMove && ! isBlockTemplatePart;
@@ -132,6 +134,7 @@ export default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {
setIsInserterOpened( false );
}
__unstableSetEditorMode( 'edit' );
+ resetZoomLevel();
__unstableContentRef.current?.focus();
} }
/>
diff --git a/packages/block-editor/src/components/tool-selector/index.js b/packages/block-editor/src/components/tool-selector/index.js
index bf55c78caf489..53fab037ba368 100644
--- a/packages/block-editor/src/components/tool-selector/index.js
+++ b/packages/block-editor/src/components/tool-selector/index.js
@@ -18,6 +18,7 @@ import { Icon, edit as editIcon } from '@wordpress/icons';
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';
+import { unlock } from '../../lock-unlock';
const selectIcon = (