Skip to content

Commit

Permalink
Merge branch 'WordPress:trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
karthick-murugan authored Dec 23, 2024
2 parents 27e4bbc + ea7bc78 commit 52f809e
Show file tree
Hide file tree
Showing 59 changed files with 428 additions and 299 deletions.
3 changes: 2 additions & 1 deletion backport-changelog/6.8/7865.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
https://github.com/WordPress/wordpress-develop/pull/7865

* https://github.com/WordPress/gutenberg/pull/66851
* https://github.com/WordPress/gutenberg/pull/66851
* https://github.com/WordPress/gutenberg/pull/68174
3 changes: 3 additions & 0 deletions backport-changelog/6.8/8032.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://github.com/WordPress/wordpress-develop/pull/8032

* https://github.com/WordPress/gutenberg/pull/68003
17 changes: 15 additions & 2 deletions bin/api-docs/gen-components-docs/markdown/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,27 @@ import json2md from 'json2md';
*/
import { generateMarkdownPropsJson } from './props.mjs';

/**
* If the string is contentful, ensure that it ends with a single newline.
* Otherwise normalize to `undefined`.
*
* @param {string} [str]
*/
function normalizeTrailingNewline( str ) {
if ( ! str?.trim() ) {
return undefined;
}
return str.replace( /\n*$/, '\n' );
}

export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
const mainDocsJson = [
{ h1: typeDocs.displayName },
'<!-- This file is generated automatically and cannot be edited directly. Make edits via TypeScript types and TSDocs. -->',
{
p: `<p class="callout callout-info">See the <a href="https://wordpress.github.io/gutenberg/?path=/docs/components-${ typeDocs.displayName.toLowerCase() }--docs">WordPress Storybook</a> for more detailed, interactive documentation.</p>`,
},
typeDocs.description,
normalizeTrailingNewline( typeDocs.description ),
...generateMarkdownPropsJson( typeDocs.props ),
];

Expand All @@ -26,7 +39,7 @@ export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
{
h3: subcomponentTypeDoc.displayName,
},
subcomponentTypeDoc.description,
normalizeTrailingNewline( subcomponentTypeDoc.description ),
...generateMarkdownPropsJson( subcomponentTypeDoc.props, {
headingLevel: 4,
} ),
Expand Down
4 changes: 2 additions & 2 deletions lib/block-supports/block-style-variations.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ function gutenberg_render_block_style_variation_support_styles( $parsed_block )
* block attributes in the `render_block_data` filter gets applied to the
* block's markup.
*
* @see gutenberg_render_block_style_variation_support_styles
*
* @since 6.6.0
*
* @see gutenberg_render_block_style_variation_support_styles
*
* @param string $block_content Rendered block content.
* @param array $block Block object.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.8/site-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@ function gutenberg_add_styles_submenu_item() {
}
}
}
add_action( 'admin_init', 'gutenberg_add_styles_submenu_item' );
add_action( 'admin_menu', 'gutenberg_add_styles_submenu_item' );
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
color: $white;
padding: 0;

// TODO: Consider passing size="small" to the Inserter toggle instead.
// Special dimensions for this button.
min-width: $button-size-small;
height: $button-size-small;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
color: $white;
padding: 0;

// TODO: Consider passing size="small" to the Inserter toggle instead.
// Special dimensions for this button.
min-width: $button-size-small;
height: $button-size-small;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import { usePatternCategories } from '../block-patterns-tab/use-pattern-categori

function PatternsExplorer( { initialCategory, rootClientId } ) {
const [ searchValue, setSearchValue ] = useState( '' );
const [ selectedCategory, setSelectedCategory ] = useState(
initialCategory?.name
);
const [ selectedCategory, setSelectedCategory ] =
useState( initialCategory );

const patternCategories = usePatternCategories( rootClientId );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ function BlockPatternsTab( {
) }
{ showPatternsExplorer && (
<PatternsExplorerModal
initialCategory={ selectedCategory || categories[ 0 ] }
initialCategory={
selectedCategory?.name || categories[ 0 ]?.name
}
patternCategories={ categories }
onModalClose={ () => setShowPatternsExplorer( false ) }
rootClientId={ rootClientId }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ export function PatternCategoryPreviews( {
return false;
}

if ( category.name === allPatternsCategory.name ) {
if ( category.name === allPatternsCategory?.name ) {
return true;
}

if (
category.name === myPatternsCategory.name &&
category.name === myPatternsCategory?.name &&
pattern.type === INSERTER_PATTERN_TYPES.user
) {
return true;
}

if (
category.name === starterPatternsCategory.name &&
category.name === starterPatternsCategory?.name &&
pattern.blockTypes?.includes( 'core/post-content' )
) {
return true;
Expand Down Expand Up @@ -149,7 +149,7 @@ export function PatternCategoryPreviews( {
level={ 4 }
as="div"
>
{ category.label }
{ category?.label }
</Heading>
</FlexBlock>
<PatternsFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
const getShouldDisableSyncFilter = ( sourceFilter ) =>
sourceFilter !== 'all' && sourceFilter !== 'user';
const getShouldHideSourcesFilter = ( category ) => {
return category.name === myPatternsCategory.name;
return category?.name === myPatternsCategory.name;
};

const PATTERN_SOURCE_MENU_OPTIONS = [
Expand Down Expand Up @@ -60,7 +60,7 @@ export function PatternsFilter( {
// the user may be confused when switching to another category if the haven't explicity set
// this filter themselves.
const currentPatternSourceFilter =
category.name === myPatternsCategory.name
category?.name === myPatternsCategory.name
? INSERTER_PATTERN_TYPES.user
: patternSourceFilter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ function CategoryTabs( {
key={ category.name }
tabId={ category.name }
aria-current={
category === selectedCategory ? 'true' : undefined
category.name === selectedCategory?.name
? 'true'
: undefined
}
>
{ category.label }
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/components/inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const defaultRenderToggle = ( {

return (
<Wrapper
__next40pxDefaultSize={ toggleProps.as ? undefined : true }
icon={ plus }
label={ label }
tooltipPosition="bottom"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
__experimentalInputControlSuffixWrapper as InputControlSuffixWrapper,
withFilters,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';
import { useState, useEffect } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { keyboardReturn } from '@wordpress/icons';
Expand Down Expand Up @@ -482,7 +482,7 @@ export function MediaPlaceholder( {
) }
onClick={ openFileDialog }
>
{ __( 'Upload' ) }
{ _x( 'Upload', 'verb' ) }
</Button>
{ uploadMediaLibraryButton }
{ renderUrlSelectionUI() }
Expand Down Expand Up @@ -512,7 +512,7 @@ export function MediaPlaceholder( {
'block-editor-media-placeholder__upload-button'
) }
>
{ __( 'Upload' ) }
{ _x( 'Upload', 'verb' ) }
</Button>
) }
onChange={ onUpload }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import clsx from 'clsx';
* WordPress dependencies
*/
import { useRef } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';
import { speak } from '@wordpress/a11y';
import {
FormFileUpload,
Expand Down Expand Up @@ -188,7 +188,7 @@ const MediaReplaceFlow = ( {
openFileDialog();
} }
>
{ __( 'Upload' ) }
{ _x( 'Upload', 'verb' ) }
</MenuItem>
);
} }
Expand Down
12 changes: 10 additions & 2 deletions packages/block-editor/src/hooks/use-zoom-out.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
* WordPress dependencies
*/
import { useSelect, useDispatch } from '@wordpress/data';
import { useEffect, useRef } from '@wordpress/element';
import { useEffect, useRef, useContext } from '@wordpress/element';

/**
* Internal dependencies
*/
import { store as blockEditorStore } from '../store';
import { unlock } from '../lock-unlock';
import BlockContext from '../components/block-context';

/**
* A hook used to set the editor mode to zoomed out mode, invoking the hook sets the mode.
Expand All @@ -19,6 +20,7 @@ import { unlock } from '../lock-unlock';
* @param {boolean} enabled If we should enter into zoomOut mode or not
*/
export function useZoomOut( enabled = true ) {
const { postId } = useContext( BlockContext );
const { setZoomLevel, resetZoomLevel } = unlock(
useDispatch( blockEditorStore )
);
Expand All @@ -37,6 +39,7 @@ export function useZoomOut( enabled = true ) {

const controlZoomLevelRef = useRef( false );
const isEnabledRef = useRef( enabled );
const postIdRef = useRef( postId );

/**
* This hook tracks if the zoom state was changed manually by the user via clicking
Expand All @@ -55,6 +58,11 @@ export function useZoomOut( enabled = true ) {
useEffect( () => {
isEnabledRef.current = enabled;

// If the user created a new post/page, we should take control of the zoom level.
if ( postIdRef.current !== postId ) {
controlZoomLevelRef.current = true;
}

if ( enabled !== isZoomOut() ) {
controlZoomLevelRef.current = true;

Expand All @@ -71,5 +79,5 @@ export function useZoomOut( enabled = true ) {
resetZoomLevel();
}
};
}, [ enabled, isZoomOut, resetZoomLevel, setZoomLevel ] );
}, [ enabled, isZoomOut, postId, resetZoomLevel, setZoomLevel ] );
}
12 changes: 5 additions & 7 deletions packages/block-library/src/cover/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ describe( 'Cover block', () => {

await selectBlock( 'Block: Cover' );
expect(
screen.getByRole( 'heading', {
name: 'Settings',
} )
await screen.findByRole( 'heading', { name: 'Settings' } )
).toBeInTheDocument();
} );
} );
Expand All @@ -216,7 +214,7 @@ describe( 'Cover block', () => {
);
await selectBlock( 'Block: Cover' );
await userEvent.click(
screen.getByLabelText( 'Fixed background' )
await screen.findByLabelText( 'Fixed background' )
);
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
'has-parallax'
Expand All @@ -232,7 +230,7 @@ describe( 'Cover block', () => {
);
await selectBlock( 'Block: Cover' );
await userEvent.click(
screen.getByLabelText( 'Repeated background' )
await screen.findByLabelText( 'Repeated background' )
);
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
'is-repeated'
Expand All @@ -245,7 +243,7 @@ describe( 'Cover block', () => {
} );

await selectBlock( 'Block: Cover' );
await userEvent.clear( screen.getByLabelText( 'Left' ) );
await userEvent.clear( await screen.findByLabelText( 'Left' ) );
await userEvent.type( screen.getByLabelText( 'Left' ), '100' );

expect(
Expand All @@ -262,7 +260,7 @@ describe( 'Cover block', () => {

await selectBlock( 'Block: Cover' );
await userEvent.type(
screen.getByLabelText( 'Alternative text' ),
await screen.findByLabelText( 'Alternative text' ),
'Me'
);
expect( screen.getByAltText( 'Me' ) ).toBeInTheDocument();
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/navigation-submenu/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
getColors,
getNavigationChildBlockProps,
} from '../navigation/edit/utils';
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';

const ALLOWED_BLOCKS = [
'core/navigation-link',
Expand Down Expand Up @@ -153,6 +154,7 @@ export default function NavigationSubmenuEdit( {
const isDraggingWithin = useIsDraggingWithin( listItemRef );
const itemLabelPlaceholder = __( 'Add text…' );
const ref = useRef();
const dropdownMenuProps = useToolsPanelDropdownMenuProps();

const {
parentCount,
Expand Down Expand Up @@ -394,6 +396,7 @@ export default function NavigationSubmenuEdit( {
rel: '',
} );
} }
dropdownMenuProps={ dropdownMenuProps }
>
<ToolsPanelItem
label={ __( 'Text' ) }
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,8 @@ private static function get_responsive_container_markup( $attributes, $inner_blo
$inner_blocks_html,
$toggle_aria_label_open,
$toggle_aria_label_close,
esc_attr( implode( ' ', $responsive_container_classes ) ),
esc_attr( implode( ' ', $open_button_classes ) ),
esc_attr( trim( implode( ' ', $responsive_container_classes ) ) ),
esc_attr( trim( implode( ' ', $open_button_classes ) ) ),
( ! empty( $overlay_inline_styles ) ) ? "style=\"$overlay_inline_styles\"" : '',
$toggle_button_content,
$toggle_close_button_content,
Expand Down
Loading

0 comments on commit 52f809e

Please sign in to comment.