Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/deprecated-call-in-test
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto committed Sep 27, 2023
2 parents 0580022 + a1151dc commit 89839f6
Show file tree
Hide file tree
Showing 48 changed files with 714 additions and 195 deletions.
4 changes: 4 additions & 0 deletions lib/compat/wordpress-6.3/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ function _gutenberg_get_iframed_editor_assets() {
}
}

// Remove the deprecated `print_emoji_styles` handler.
// It avoids breaking style generation with a deprecation message.
remove_action( 'wp_print_styles', 'print_emoji_styles' );
ob_start();
wp_print_styles();
$styles = ob_get_clean();
add_action( 'wp_print_styles', 'print_emoji_styles' );

ob_start();
wp_print_head_scripts();
Expand Down
13 changes: 13 additions & 0 deletions lib/compat/wordpress-6.4/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,23 @@ function _gutenberg_get_iframed_editor_assets_6_4() {
}
}

/**
* Remove the deprecated `print_emoji_styles` handler.
* It avoids breaking style generation with a deprecation message.
*/
$has_emoji_styles = has_action( 'wp_print_styles', 'print_emoji_styles' );
if ( $has_emoji_styles ) {
remove_action( 'wp_print_styles', 'print_emoji_styles' );
}

ob_start();
wp_print_styles();
$styles = ob_get_clean();

if ( $has_emoji_styles ) {
add_action( 'wp_print_styles', 'print_emoji_styles' );
}

ob_start();
wp_print_head_scripts();
wp_print_footer_scripts();
Expand Down
120 changes: 60 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function BlockPatternList(
onHover,
onClickPattern,
orientation,
label = __( 'Block Patterns' ),
label = __( 'Block patterns' ),
showTitlesAsTooltip,
pagingProps,
},
Expand Down Expand Up @@ -180,9 +180,7 @@ function BlockPatternList(
<BlockPatternPlaceholder key={ pattern.name } />
);
} ) }
{ pagingProps && pagingProps.numPages > 1 && (
<BlockPatternsPaging { ...pagingProps } />
) }
{ pagingProps && <BlockPatternsPaging { ...pagingProps } /> }
</Composite>
);
}
Expand Down
111 changes: 57 additions & 54 deletions packages/block-editor/src/components/block-patterns-paging/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,66 +27,69 @@ export default function Pagination( {
)
}
</Text>
<HStack
expanded={ false }
spacing={ 3 }
justify="flex-start"
className="block-editor-patterns__grid-pagination"
>
<HStack
expanded={ false }
spacing={ 1 }
className="block-editor-patterns__grid-pagination-previous"
>
<Button
variant="tertiary"
onClick={ () => changePage( 1 ) }
disabled={ currentPage === 1 }
aria-label={ __( 'First page' ) }
>
<span>«</span>
</Button>
<Button
variant="tertiary"
onClick={ () => changePage( currentPage - 1 ) }
disabled={ currentPage === 1 }
aria-label={ __( 'Previous page' ) }
>
<span></span>
</Button>
</HStack>
<Text variant="muted">
{ sprintf(
// translators: %1$s: Current page number, %2$s: Total number of pages.
_x( '%1$s of %2$s', 'paging' ),
currentPage,
numPages
) }
</Text>

{ numPages > 1 && (
<HStack
expanded={ false }
spacing={ 1 }
className="block-editor-patterns__grid-pagination-next"
spacing={ 3 }
justify="flex-start"
className="block-editor-patterns__grid-pagination"
>
<Button
variant="tertiary"
onClick={ () => changePage( currentPage + 1 ) }
disabled={ currentPage === numPages }
aria-label={ __( 'Next page' ) }
<HStack
expanded={ false }
spacing={ 1 }
className="block-editor-patterns__grid-pagination-previous"
>
<span></span>
</Button>
<Button
variant="tertiary"
onClick={ () => changePage( numPages ) }
disabled={ currentPage === numPages }
aria-label={ __( 'Last page' ) }
size="default"
<Button
variant="tertiary"
onClick={ () => changePage( 1 ) }
disabled={ currentPage === 1 }
aria-label={ __( 'First page' ) }
>
<span>«</span>
</Button>
<Button
variant="tertiary"
onClick={ () => changePage( currentPage - 1 ) }
disabled={ currentPage === 1 }
aria-label={ __( 'Previous page' ) }
>
<span></span>
</Button>
</HStack>
<Text variant="muted">
{ sprintf(
// translators: %1$s: Current page number, %2$s: Total number of pages.
_x( '%1$s of %2$s', 'paging' ),
currentPage,
numPages
) }
</Text>
<HStack
expanded={ false }
spacing={ 1 }
className="block-editor-patterns__grid-pagination-next"
>
<span>»</span>
</Button>
<Button
variant="tertiary"
onClick={ () => changePage( currentPage + 1 ) }
disabled={ currentPage === numPages }
aria-label={ __( 'Next page' ) }
>
<span></span>
</Button>
<Button
variant="tertiary"
onClick={ () => changePage( numPages ) }
disabled={ currentPage === numPages }
aria-label={ __( 'Last page' ) }
size="default"
>
<span>»</span>
</Button>
</HStack>
</HStack>
</HStack>
) }
</VStack>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Hermes has a limit for the call stack depth to avoid infinite recursion.
// When creating a deep nested structure of inner blocks, the editor might exceed
// this limit and crash. In order to avoid this, we set a maximum depth level where
// we stop rendering blocks.
export const MAX_NESTING_DEPTH = 10;
15 changes: 15 additions & 0 deletions packages/block-editor/src/components/inner-blocks/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import { __unstableGetInnerBlocksProps as getInnerBlocksProps } from '@wordpress/blocks';
import { useRef } from '@wordpress/element';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -21,6 +22,9 @@ import { useBlockEditContext } from '../block-edit/context';
import useBlockSync from '../provider/use-block-sync';
import { BlockContextProvider } from '../block-context';
import { defaultLayout, LayoutProvider } from '../block-list/layout';
import { store as blockEditorStore } from '../../store';
import WarningMaxDepthExceeded from './warning-max-depth-exceeded';
import { MAX_NESTING_DEPTH } from './constants';

/**
* This hook is used to lightly mark an element as an inner blocks wrapper
Expand Down Expand Up @@ -122,6 +126,17 @@ function UncontrolledInnerBlocks( props ) {
templateInsertUpdatesSelection
);

const nestingLevel = useSelect(
( select ) => {
return select( blockEditorStore ).getBlockParents( clientId )
?.length;
},
[ clientId ]
);
if ( nestingLevel >= MAX_NESTING_DEPTH ) {
return <WarningMaxDepthExceeded clientId={ clientId } />;
}

return (
<LayoutProvider value={ layout }>
<BlockContextProvider value={ context }>
Expand Down
Loading

0 comments on commit 89839f6

Please sign in to comment.