Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only prioritise Quote transform where relevant #57749

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand All @@ -49,6 +49,17 @@ function useGroupedTransforms( possibleBlockTransformations ) {
},
{ priorityTextTransformations: [], restTransformations: [] }
);
if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding an explanatory comment as to why we don't want core/quote to be the only priority transform? Just wondered if it'd help anyone looking at this further down the track to know why there's a bit of extra code to shove it out of the way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, that's a great point! It should be made clear that if the priority list changes, this code might have to change too.

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.
Expand Down
Loading