diff --git a/backport-changelog/6.8/7903.md b/backport-changelog/6.8/7903.md index cb20d8d2dd2b1..60703831a8e39 100644 --- a/backport-changelog/6.8/7903.md +++ b/backport-changelog/6.8/7903.md @@ -1,3 +1,5 @@ https://github.com/WordPress/wordpress-develop/pull/7903 * https://github.com/WordPress/gutenberg/pull/67199 +* https://github.com/WordPress/gutenberg/pull/68971 + diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 3579b9b81bf48..6a8f3255297c4 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -14,7 +14,7 @@ Display a date archive of your posts. ([Source](https://github.com/WordPress/gut - **Name:** core/archives - **Category:** widgets -- **Supports:** align, interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ +- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), typography (fontSize, lineHeight), ~~html~~ - **Attributes:** displayAsDropdown, showLabel, showPostCounts, type ## Audio diff --git a/lib/compat/wordpress-6.8/site-editor.php b/lib/compat/wordpress-6.8/site-editor.php index 9b2575676047d..82ac118b013c1 100644 --- a/lib/compat/wordpress-6.8/site-editor.php +++ b/lib/compat/wordpress-6.8/site-editor.php @@ -15,6 +15,16 @@ function ( $settings ) { } ); +/** + * Maps old site editor urls to the new updated ones. + * + * @since 6.8.0 + * @access private + * + * @global string $pagenow The filename of the current screen. + * + * @return string|false The new URL to redirect to, or false if no redirection is needed. + */ function gutenberg_get_site_editor_redirection() { global $pagenow; if ( 'site-editor.php' !== $pagenow || isset( $_REQUEST['p'] ) || ! $_SERVER['QUERY_STRING'] ) { @@ -96,10 +106,13 @@ function gutenberg_get_site_editor_redirection() { return add_query_arg( array( 'p' => '/' ) ); } +/** + * Redirect old site editor urls to the new updated ones. + */ function gutenberg_redirect_site_editor_deprecated_urls() { $redirection = gutenberg_get_site_editor_redirection(); if ( false !== $redirection ) { - wp_redirect( $redirection, 301 ); + wp_safe_redirect( $redirection ); exit; } } diff --git a/packages/block-directory/src/components/downloadable-blocks-panel/no-results.js b/packages/block-directory/src/components/downloadable-blocks-panel/no-results.js index f2344061f9566..e4d04cd244687 100644 --- a/packages/block-directory/src/components/downloadable-blocks-panel/no-results.js +++ b/packages/block-directory/src/components/downloadable-blocks-panel/no-results.js @@ -2,17 +2,12 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { Icon, blockDefault } from '@wordpress/icons'; import { Tip, ExternalLink } from '@wordpress/components'; function DownloadableBlocksNoResults() { return ( <>
-

{ __( 'No results found.' ) }

diff --git a/packages/block-editor/src/components/block-list/index.js b/packages/block-editor/src/components/block-list/index.js index d3a2f0ae0795c..61c5cc277c135 100644 --- a/packages/block-editor/src/components/block-list/index.js +++ b/packages/block-editor/src/components/block-list/index.js @@ -201,6 +201,11 @@ function Items( { getDefaultBlockName(), rootClientId ) ); + const hasSelectedRoot = !! ( + rootClientId && + selectedBlockClientId && + rootClientId === selectedBlockClientId + ); return { order: _order, @@ -214,8 +219,8 @@ function Items( { hasAppender && ! _isZoomOut() && ( hasCustomAppender || - showRootAppender || - rootClientId === selectedBlockClientId ), + hasSelectedRoot || + showRootAppender ), }; }, [ rootClientId, hasAppender, hasCustomAppender ] diff --git a/packages/block-editor/src/components/global-styles/shadow-panel-components.js b/packages/block-editor/src/components/global-styles/shadow-panel-components.js index 1cfdff0be286e..c335ef29384f4 100644 --- a/packages/block-editor/src/components/global-styles/shadow-panel-components.js +++ b/packages/block-editor/src/components/global-styles/shadow-panel-components.js @@ -13,8 +13,8 @@ import { Composite, Tooltip, } from '@wordpress/components'; -import { useMemo } from '@wordpress/element'; -import { shadow as shadowIcon, Icon, check } from '@wordpress/icons'; +import { useMemo, useRef } from '@wordpress/element'; +import { shadow as shadowIcon, Icon, check, reset } from '@wordpress/icons'; /** * External dependencies @@ -119,7 +119,7 @@ export function ShadowPopover( { shadow, onShadowChange, settings } ) { ( { + const shadowButtonRef = useRef( undefined ); + const toggleProps = { onClick: onToggle, className: clsx( { 'is-open': isOpen } ), 'aria-expanded': isOpen, + ref: shadowButtonRef, + }; + + const removeButtonProps = { + onClick: () => { + if ( isOpen ) { + onToggle(); + } + onShadowChange( undefined ); + // Return focus to parent button. + shadowButtonRef.current?.focus(); + }, + className: clsx( + 'block-editor-global-styles__shadow-editor__remove-button', + { 'is-open': isOpen } + ), + label: __( 'Remove' ), }; return ( - + { !! shadow && ( + + ) } + ); }; } diff --git a/packages/block-editor/src/components/global-styles/style.scss b/packages/block-editor/src/components/global-styles/style.scss index c51ffa3116d9f..5684cf9c0d303 100644 --- a/packages/block-editor/src/components/global-styles/style.scss +++ b/packages/block-editor/src/components/global-styles/style.scss @@ -24,6 +24,7 @@ .block-editor-global-styles__shadow-dropdown { display: block; padding: 0; + position: relative; button { width: 100%; @@ -35,6 +36,28 @@ } } +.block-editor-global-styles__shadow-editor__remove-button { + position: absolute; + right: 0; + top: $grid-unit; + margin: auto $grid-unit auto; + opacity: 0; + @media not (prefers-reduced-motion) { + transition: opacity 0.1s ease-in-out; + } + + .block-editor-global-styles__shadow-dropdown:hover &, + &:focus, + &:hover { + opacity: 1; + } + + @media (hover: none) { + // Show reset button on devices that do not support hover. + opacity: 1; + } +} + // These styles are similar to the color palette. .block-editor-global-styles__shadow-indicator { appearance: none; diff --git a/packages/block-editor/src/components/inner-blocks/index.js b/packages/block-editor/src/components/inner-blocks/index.js index ae58772027820..58faf9f9a34e1 100644 --- a/packages/block-editor/src/components/inner-blocks/index.js +++ b/packages/block-editor/src/components/inner-blocks/index.js @@ -174,11 +174,11 @@ const ForwardedInnerBlocks = forwardRef( ( props, ref ) => { * returns. Optionally, you can also pass any other props through this hook, and * they will be merged and returned. * + * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md + * * @param {Object} props Optional. Props to pass to the element. Must contain * the ref if one is defined. * @param {Object} options Optional. Inner blocks options. - * - * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md */ export function useInnerBlocksProps( props = {}, options = {} ) { const { diff --git a/packages/block-editor/src/components/inner-blocks/index.native.js b/packages/block-editor/src/components/inner-blocks/index.native.js index 1398a5abd51e4..635c44d2e085c 100644 --- a/packages/block-editor/src/components/inner-blocks/index.native.js +++ b/packages/block-editor/src/components/inner-blocks/index.native.js @@ -35,11 +35,11 @@ import { MAX_NESTING_DEPTH } from './constants'; * returns. Optionally, you can also pass any other props through this hook, and * they will be merged and returned. * + * @see https://github.com/WordPress/gutenberg/blob/master/packages/block-editor/src/components/inner-blocks/README.md + * * @param {Object} props Optional. Props to pass to the element. Must contain * the ref if one is defined. * @param {Object} options Optional. Inner blocks options. - * - * @see https://github.com/WordPress/gutenberg/blob/master/packages/block-editor/src/components/inner-blocks/README.md */ export function useInnerBlocksProps( props = {}, options = {} ) { const fallbackRef = useRef(); diff --git a/packages/block-editor/src/components/inserter/no-results.js b/packages/block-editor/src/components/inserter/no-results.js index 3ca6569dc14ea..e005622f3cf3d 100644 --- a/packages/block-editor/src/components/inserter/no-results.js +++ b/packages/block-editor/src/components/inserter/no-results.js @@ -2,15 +2,10 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { Icon, blockDefault } from '@wordpress/icons'; function InserterNoResults() { return (
-

{ __( 'No results found.' ) }

); diff --git a/packages/block-library/src/archives/block.json b/packages/block-library/src/archives/block.json index 7fe956a994ed5..0351a4b694c00 100644 --- a/packages/block-library/src/archives/block.json +++ b/packages/block-library/src/archives/block.json @@ -54,6 +54,15 @@ "fontSize": true } }, + "color": { + "gradients": true, + "link": true, + "__experimentalDefaultControls": { + "background": true, + "text": true, + "link": true + } + }, "interactivity": { "clientNavigation": true } diff --git a/packages/block-library/src/social-links/editor.scss b/packages/block-library/src/social-links/editor.scss index 11f1ed86d1122..54a4154659eb2 100644 --- a/packages/block-library/src/social-links/editor.scss +++ b/packages/block-library/src/social-links/editor.scss @@ -89,7 +89,6 @@ // Unconfigured placeholder links are semitransparent. .wp-social-link.wp-social-link__is-incomplete { opacity: 0.5; - @include reduce-motion("transition"); } .wp-block-social-links .is-selected .wp-social-link__is-incomplete, diff --git a/packages/edit-site/src/components/media/index.js b/packages/edit-site/src/components/media/index.js index e103e6bcddb5b..0e0c7abaae464 100644 --- a/packages/edit-site/src/components/media/index.js +++ b/packages/edit-site/src/components/media/index.js @@ -6,11 +6,11 @@ import { useEntityRecord } from '@wordpress/core-data'; function Media( { id, size = [ 'large', 'medium', 'thumbnail' ], ...props } ) { const { record: media } = useEntityRecord( 'root', 'media', id ); const currentSize = size.find( - ( s ) => !! media?.media_details?.sizes[ s ] + ( s ) => !! media?.media_details?.sizes?.[ s ] ); const mediaUrl = - media?.media_details?.sizes[ currentSize ]?.source_url || + media?.media_details?.sizes?.[ currentSize ]?.source_url || media?.source_url; if ( ! mediaUrl ) { diff --git a/packages/editor/src/components/editor/index.js b/packages/editor/src/components/editor/index.js index 21becea43cd7e..80c5419caf997 100644 --- a/packages/editor/src/components/editor/index.js +++ b/packages/editor/src/components/editor/index.js @@ -31,12 +31,17 @@ function Editor( { extraSidebarPanels, ...props } ) { - const { post, template, hasLoadedPost } = useSelect( + const { post, template, hasLoadedPost, error } = useSelect( ( select ) => { - const { getEntityRecord, hasFinishedResolution } = - select( coreStore ); + const { + getEntityRecord, + getResolutionError, + hasFinishedResolution, + } = select( coreStore ); + + const postArgs = [ 'postType', postType, postId ]; return { - post: getEntityRecord( 'postType', postType, postId ), + post: getEntityRecord( ...postArgs ), template: templateId ? getEntityRecord( 'postType', @@ -44,11 +49,12 @@ function Editor( { templateId ) : undefined, - hasLoadedPost: hasFinishedResolution( 'getEntityRecord', [ - 'postType', - postType, - postId, - ] ), + hasLoadedPost: hasFinishedResolution( + 'getEntityRecord', + postArgs + ), + error: getResolutionError( 'getEntityRecord', postArgs ) + ?.message, }; }, [ postType, postId, templateId ] @@ -57,10 +63,15 @@ function Editor( { return ( <> { hasLoadedPost && ! post && ( - - { __( - "You attempted to edit an item that doesn't exist. Perhaps it was deleted?" - ) } + + { ! error + ? __( + "You attempted to edit an item that doesn't exist. Perhaps it was deleted?" + ) + : error } ) } { !! post && ( diff --git a/test/integration/fixtures/blocks/core__separator-color.json b/test/integration/fixtures/blocks/core__separator-color.json index d66a8b2e1a242..d53b728742803 100644 --- a/test/integration/fixtures/blocks/core__separator-color.json +++ b/test/integration/fixtures/blocks/core__separator-color.json @@ -4,8 +4,8 @@ "isValid": true, "attributes": { "opacity": "alpha-channel", - "backgroundColor": "accent", - "tagName": "hr" + "tagName": "hr", + "backgroundColor": "accent" }, "innerBlocks": [] } diff --git a/test/integration/fixtures/blocks/core__separator-custom-color.json b/test/integration/fixtures/blocks/core__separator-custom-color.json index 9b126f2b5be6c..444cf3cf9b19b 100644 --- a/test/integration/fixtures/blocks/core__separator-custom-color.json +++ b/test/integration/fixtures/blocks/core__separator-custom-color.json @@ -4,12 +4,12 @@ "isValid": true, "attributes": { "opacity": "alpha-channel", + "tagName": "hr", "style": { "color": { "background": "#5da54c" } - }, - "tagName": "hr" + } }, "innerBlocks": [] }