From dcca1219f34f338d120706f4fb92e5a3107e3b2e Mon Sep 17 00:00:00 2001 From: yogeshbhutkar Date: Thu, 26 Dec 2024 12:19:00 +0530 Subject: [PATCH 1/3] Zoom Out Inserter: enable --- .../data/data-core-block-editor.md | 24 +++++++++++++++++++ .../block-list/zoom-out-separator.js | 11 +++++++-- .../zoom-out-mode-inserter-button.js | 19 +++++++++++---- .../src/components/inserter/menu.js | 12 ++++++++-- packages/block-editor/src/store/actions.js | 14 +++++++++++ packages/block-editor/src/store/reducer.js | 18 ++++++++++++++ packages/block-editor/src/store/selectors.js | 11 +++++++++ 7 files changed, 101 insertions(+), 8 deletions(-) diff --git a/docs/reference-guides/data/data-core-block-editor.md b/docs/reference-guides/data/data-core-block-editor.md index bca05d57610934..80be4dfb7bfa41 100644 --- a/docs/reference-guides/data/data-core-block-editor.md +++ b/docs/reference-guides/data/data-core-block-editor.md @@ -827,6 +827,18 @@ _Returns_ - `0|-1|null`: Initial position. +### getSelectedTab + +Returns the selected tab. + +_Parameters_ + +- _state_ `Object`: Global application state. + +_Returns_ + +- `string`: The selected tab. + ### getSelectionEnd Returns the current selection end block client ID, attribute key and text offset. @@ -1721,6 +1733,18 @@ _Parameters_ - _isNavigationMode_ `boolean`: Enable/Disable navigation mode. +### setSelectedTab + +Sets the selected tab. + +_Parameters_ + +- _tab_ `string`: The selected tab. Can be `patterns`, `blocks` or `media`. + +_Returns_ + +- `Object`: Action object. + ### setTemplateValidity Action that resets the template validity. diff --git a/packages/block-editor/src/components/block-list/zoom-out-separator.js b/packages/block-editor/src/components/block-list/zoom-out-separator.js index 86191c1e4ce32c..95acc9e36dc00a 100644 --- a/packages/block-editor/src/components/block-list/zoom-out-separator.js +++ b/packages/block-editor/src/components/block-list/zoom-out-separator.js @@ -13,7 +13,7 @@ import { import { useReducedMotion } from '@wordpress/compose'; import { useSelect } from '@wordpress/data'; import { useState } from '@wordpress/element'; -import { __ } from '@wordpress/i18n'; +import { __, sprintf } from '@wordpress/i18n'; /** * Internal dependencies @@ -34,6 +34,7 @@ export function ZoomOutSeparator( { blockInsertionPointVisible, blockInsertionPoint, blocksBeingDragged, + selectedTab, } = useSelect( ( select ) => { const { getInsertionPoint, @@ -42,6 +43,7 @@ export function ZoomOutSeparator( { isBlockInsertionPointVisible, getBlockInsertionPoint, getDraggedBlockClientIds, + getSelectedTab, } = unlock( select( blockEditorStore ) ); const root = getSectionRootClientId(); @@ -54,6 +56,7 @@ export function ZoomOutSeparator( { blockInsertionPoint: getBlockInsertionPoint(), blockInsertionPointVisible: isBlockInsertionPointVisible(), blocksBeingDragged: getDraggedBlockClientIds(), + selectedTab: getSelectedTab(), }; }, [] ); @@ -162,7 +165,11 @@ export function ZoomOutSeparator( { delay: 0.125, } } > - { __( 'Drop pattern.' ) } + { sprintf( + /* translators: %s: tab name (e.g. "pattern" or "block") */ + __( 'Drop %s.' ), + selectedTab + ) } ) } diff --git a/packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js b/packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js index 961552caa66e01..b8658672b59a7a 100644 --- a/packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js +++ b/packages/block-editor/src/components/block-tools/zoom-out-mode-inserter-button.js @@ -6,11 +6,21 @@ import clsx from 'clsx'; /** * WordPress dependencies */ +import { useSelect } from '@wordpress/data'; import { Button } from '@wordpress/components'; import { plus } from '@wordpress/icons'; -import { _x } from '@wordpress/i18n'; +import { _x, sprintf } from '@wordpress/i18n'; + +/** + * Internal dependencies + */ +import { store as blockEditorStore } from '../../store'; function ZoomOutModeInserterButton( { onClick } ) { + const selectedTab = useSelect( ( select ) => { + return select( blockEditorStore ).getSelectedTab(); + }, [] ); + return (