From f9ee040f4060095d9a88918543a576bd5fecb323 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Thu, 11 Jan 2024 17:12:16 +1100 Subject: [PATCH 1/2] Only prioritise Quote transform where relevant --- .../block-switcher/block-transformations-menu.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/block-switcher/block-transformations-menu.js b/packages/block-editor/src/components/block-switcher/block-transformations-menu.js index 033201d7facadb..d2270ae0d8896f 100644 --- a/packages/block-editor/src/components/block-switcher/block-transformations-menu.js +++ b/packages/block-editor/src/components/block-switcher/block-transformations-menu.js @@ -37,7 +37,7 @@ function useGroupedTransforms( possibleBlockTransformations ) { const priorityTextTranformsNames = Object.keys( priorityContentTranformationBlocks ); - return possibleBlockTransformations.reduce( + const groupedPossibleTransforms = possibleBlockTransformations.reduce( ( accumulator, item ) => { const { name } = item; if ( priorityTextTranformsNames.includes( name ) ) { @@ -49,6 +49,17 @@ function useGroupedTransforms( possibleBlockTransformations ) { }, { priorityTextTransformations: [], restTransformations: [] } ); + if ( + groupedPossibleTransforms.priorityTextTransformations.length === + 1 && + groupedPossibleTransforms.priorityTextTransformations[ 0 ].name === + 'core/quote' + ) { + const singleQuote = + groupedPossibleTransforms.priorityTextTransformations.pop(); + groupedPossibleTransforms.restTransformations.push( singleQuote ); + } + return groupedPossibleTransforms; }, [ possibleBlockTransformations ] ); // Order the priority text transformations. From 4b3db586b2892502df76f54138837b9fee6c2d50 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Fri, 12 Jan 2024 09:58:08 +1100 Subject: [PATCH 2/2] Add explanatory comment. --- .../components/block-switcher/block-transformations-menu.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/block-editor/src/components/block-switcher/block-transformations-menu.js b/packages/block-editor/src/components/block-switcher/block-transformations-menu.js index d2270ae0d8896f..271b7fabd51731 100644 --- a/packages/block-editor/src/components/block-switcher/block-transformations-menu.js +++ b/packages/block-editor/src/components/block-switcher/block-transformations-menu.js @@ -49,6 +49,12 @@ function useGroupedTransforms( possibleBlockTransformations ) { }, { priorityTextTransformations: [], restTransformations: [] } ); + /** + * If there is only one priority text transformation and it's a Quote, + * is should move to the rest transformations. This is because Quote can + * be a container for any block type, so in multi-block selection it will + * always be suggested, even for non-text blocks. + */ if ( groupedPossibleTransforms.priorityTextTransformations.length === 1 &&