From d9fa3ac5a146f6ed47c7bb3d30baccf9bd0db632 Mon Sep 17 00:00:00 2001 From: Benazeer Hassan <66269472+benazeer-ben@users.noreply.github.com> Date: Fri, 31 Jan 2025 19:36:50 +0530 Subject: [PATCH 01/15] RSS: Border & Spacing support (#66411) * RSS block border support * Added block and spacing support for RSS block * Doc Build * Lint js fix * Lint js fix * Feed back changes * Review changes * Update packages/block-library/src/rss/editor.scss Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Update packages/block-library/src/rss/style.scss Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * Eslint fix & Format change --------- Co-authored-by: benazeer1909 <91200605+benazeerhassan1909@users.noreply.github.com> Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Unlinked contributors: benazeerhassan1909. Co-authored-by: benazeer-ben Co-authored-by: ramonjd Co-authored-by: aaronrobertshaw Co-authored-by: shail-mehta --- docs/reference-guides/core-blocks.md | 2 +- packages/block-library/src/rss/block.json | 14 ++++++++++++++ packages/block-library/src/rss/edit.js | 15 ++++++++++++++- packages/block-library/src/rss/editor.scss | 7 +++++++ packages/block-library/src/rss/style.scss | 14 ++++++-------- 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/docs/reference-guides/core-blocks.md b/docs/reference-guides/core-blocks.md index 7ac8591cd1931..3579b9b81bf48 100644 --- a/docs/reference-guides/core-blocks.md +++ b/docs/reference-guides/core-blocks.md @@ -811,7 +811,7 @@ Display entries from any RSS or Atom feed. ([Source](https://github.com/WordPres - **Name:** core/rss - **Category:** widgets -- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), ~~html~~ +- **Supports:** align, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), ~~html~~ - **Attributes:** blockLayout, columns, displayAuthor, displayDate, displayExcerpt, excerptLength, feedURL, itemsToShow ## Search diff --git a/packages/block-library/src/rss/block.json b/packages/block-library/src/rss/block.json index 844104b7d8113..112dec4a32c78 100644 --- a/packages/block-library/src/rss/block.json +++ b/packages/block-library/src/rss/block.json @@ -47,6 +47,20 @@ "interactivity": { "clientNavigation": true }, + "__experimentalBorder": { + "radius": true, + "color": true, + "width": true, + "style": true + }, + "spacing": { + "margin": true, + "padding": true, + "__experimentalDefaultControls": { + "padding": false, + "margin": false + } + }, "color": { "background": true, "text": true, diff --git a/packages/block-library/src/rss/edit.js b/packages/block-library/src/rss/edit.js index 39564da79b16e..d931bc8cb01d8 100644 --- a/packages/block-library/src/rss/edit.js +++ b/packages/block-library/src/rss/edit.js @@ -119,6 +119,19 @@ export default function RSSEdit( { attributes, setAttributes } ) { }, ]; + /* + * This function merges the existing attributes with additional style properties. + * The `border` and `spacing` properties are set to `undefined` to ensure that + * these styles are reset and not applied on the server side. + */ + const serverSideAttributes = { + ...attributes, + style: { + ...attributes?.style, + border: undefined, + spacing: undefined, + }, + }; return ( <> @@ -190,7 +203,7 @@ export default function RSSEdit( { attributes, setAttributes } ) { diff --git a/packages/block-library/src/rss/editor.scss b/packages/block-library/src/rss/editor.scss index c5e79d6254460..83fef1d73f4f3 100644 --- a/packages/block-library/src/rss/editor.scss +++ b/packages/block-library/src/rss/editor.scss @@ -5,3 +5,10 @@ .wp-block-rss__placeholder-form .wp-block-rss__placeholder-input { flex: 1 1 auto; } +// Reset all styles when skipping block supports while server-side rendering. +// This prevents issues such as duplicate padding, borders etc. +.wp-block-rss .wp-block-rss { + all: inherit; + margin: 0; + padding: 0; +} diff --git a/packages/block-library/src/rss/style.scss b/packages/block-library/src/rss/style.scss index f7360ec76f85a..76cc232044ff3 100644 --- a/packages/block-library/src/rss/style.scss +++ b/packages/block-library/src/rss/style.scss @@ -1,11 +1,4 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styles in the editor. - list-style: none; - padding: 0; - - // This needs extra specificity due to the reset mixin on the parent: https://github.com/WordPress/gutenberg/blob/a250e9e5fe00dd5195624f96a3d924e7078951c3/packages/edit-post/src/style.scss#L54 - &.wp-block-rss { - box-sizing: border-box; - } &.alignleft { /*rtl:ignore*/ @@ -19,7 +12,6 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl display: flex; flex-wrap: wrap; padding: 0; - list-style: none; li { margin: 0 1em 1em 0; @@ -41,3 +33,9 @@ ul.wp-block-rss { // The ul is needed for specificity to override the reset styl display: block; font-size: 0.8125em; } +.wp-block-rss { + // This block has customizable padding, border-box makes that more predictable. + box-sizing: border-box; + list-style: none; + padding: 0; +} From 2dd6aa1f7bdf98f83cd5bdd6e894e89a873ddc7e Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Sat, 1 Feb 2025 01:59:05 +0900 Subject: [PATCH 02/15] Regenerate block fixtures (#68982) Co-authored-by: t-hamano Co-authored-by: Mamaduka --- test/integration/fixtures/blocks/core__separator-color.json | 4 ++-- .../fixtures/blocks/core__separator-custom-color.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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": [] } From f2ea441ec7bda6dad4fdb43aac509fcee4a56abc Mon Sep 17 00:00:00 2001 From: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> Date: Sat, 1 Feb 2025 11:53:16 +1100 Subject: [PATCH 03/15] Site Editor: Use temporary redirects for deprecated URLs. (#68971) Modifies the redirects from deprecated site-editor URLs to use 302 temporary redirects rather than 301 permanent redirects. This prevents the browser from caching the redirect as the destination will differ for logged in and logged out users. This also switches from using `wp_redirect()` to `wp_safe_redirect()` in accordance with best practices when redirecting within a WordPress site. Follow up to #67199 Incorporating changes in https://github.com/WordPress/wordpress-develop/pull/7903 See https://core.trac.wordpress.org/ticket/62585 Co-authored-by: peterwilsoncc Co-authored-by: Mamaduka --- backport-changelog/6.8/7903.md | 2 ++ lib/compat/wordpress-6.8/site-editor.php | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) 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/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; } } From 24fad40a6915c4ac1b7cb1403d9930b962fd5176 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Sat, 1 Feb 2025 15:13:27 +0530 Subject: [PATCH 04/15] Changed Inline Document Order (#68992) Co-authored-by: shail-mehta Co-authored-by: Mamaduka --- packages/block-editor/src/components/inner-blocks/index.js | 4 ++-- .../block-editor/src/components/inner-blocks/index.native.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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(); From c9b256927a60011bc7bce1371c673972f84835f8 Mon Sep 17 00:00:00 2001 From: George Garside <191085+grgar@users.noreply.github.com> Date: Sun, 2 Feb 2025 06:17:15 +0000 Subject: [PATCH 05/15] Add optional chain to sizes indexing of media details in edit-site (#68995) This optional chaining is already present in 21 other lines in Gutenberg where `sizes` (in `media_details`) is indexed, but is missing on these two lines. For some reason, `media_details` is an empty object for some of my attachments on my site, so this throws a TypeError. This change resolves this issue. Co-authored-by: grgar Co-authored-by: Mamaduka --- packages/edit-site/src/components/media/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 ) { From 36690dc8b264f0434d8786b648cac8b2a31e3582 Mon Sep 17 00:00:00 2001 From: Sainath Poojary <53347682+SainathPoojary@users.noreply.github.com> Date: Mon, 3 Feb 2025 10:25:25 +0530 Subject: [PATCH 06/15] Inserter: Remove block default icon from no results message (#68693) Co-authored-by: SainathPoojary Co-authored-by: afercia --- .../src/components/downloadable-blocks-panel/no-results.js | 5 ----- packages/block-editor/src/components/inserter/no-results.js | 5 ----- 2 files changed, 10 deletions(-) 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/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.' ) }

); From 0feca715013b985b2cd7761c253fb3be5556870b Mon Sep 17 00:00:00 2001 From: Himanshu Pathak Date: Mon, 3 Feb 2025 12:59:34 +0530 Subject: [PATCH 07/15] Social Links: Remove redundant reduce-motion mixin (#69000) Co-authored-by: himanshupathak95 Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: Mayank-Tripathi32 Co-authored-by: t-hamano --- packages/block-library/src/social-links/editor.scss | 1 - 1 file changed, 1 deletion(-) 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, From be0e151a4d775a801c1fe9ab8047acefef5dbacb Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 3 Feb 2025 12:33:09 +0400 Subject: [PATCH 08/15] Editor: Display error message when loading current post fails (#68999) Co-authored-by: Mamaduka Co-authored-by: t-hamano --- .../editor/src/components/editor/index.js | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) 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 && ( From 14955603b46957a00af95f31ca5a89b75e2c05ad Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 3 Feb 2025 13:52:07 +0400 Subject: [PATCH 09/15] Block Editor: Fix regression for root appender logic (#68994) Co-authored-by: Mamaduka Co-authored-by: t-hamano --- packages/block-editor/src/components/block-list/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 ] From ebbe466a31807bb74509589859fd0ec391c2d1b8 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Mon, 3 Feb 2025 15:27:57 +0530 Subject: [PATCH 10/15] Archives: Add Color Support (#68685) * Archives: Add Color Support Co-authored-by: shail-mehta Co-authored-by: carolinan --- docs/reference-guides/core-blocks.md | 2 +- packages/block-library/src/archives/block.json | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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/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 } From 693e315bd00ac36828364bc0b0d8f1fe22b5963c Mon Sep 17 00:00:00 2001 From: Yogesh Bhutkar Date: Mon, 3 Feb 2025 15:31:45 +0530 Subject: [PATCH 11/15] Shadow Panel: Add reset button (#68981) * feat: add remove button for block editor shadow panel * refactor: simplify the markup * refactor: revert `toggle` markup and use consistent wording * a11y: return focus to parent button on reset Co-authored-by: yogeshbhutkar Co-authored-by: t-hamano Co-authored-by: Mamaduka --- .../global-styles/shadow-panel-components.js | 55 ++++++++++++++----- .../src/components/global-styles/style.scss | 23 ++++++++ 2 files changed, 65 insertions(+), 13 deletions(-) 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; From ae20971817823e3578dba3cb31130e003d79886f Mon Sep 17 00:00:00 2001 From: Akanshu Singh <61490175+singhakanshu00@users.noreply.github.com> Date: Mon, 3 Feb 2025 22:02:20 +0530 Subject: [PATCH 12/15] Disable hover animation on preview frame for classic themes (#68976) Co-authored-by: singhakanshu00 Co-authored-by: t-hamano Co-authored-by: carolinan Co-authored-by: stokesman --- packages/edit-site/src/components/resizable-frame/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/resizable-frame/index.js b/packages/edit-site/src/components/resizable-frame/index.js index ecb7204f9f05b..fee65fbd9dfff 100644 --- a/packages/edit-site/src/components/resizable-frame/index.js +++ b/packages/edit-site/src/components/resizable-frame/index.js @@ -254,7 +254,7 @@ function ResizableFrame( { } } } whileHover={ - canvas === 'view' + canvas === 'view' && isBlockTheme ? { scale: 1.005, transition: { From 51d5372bc4d5a9daa6260f1c5d4619d4f43aa299 Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:49:25 +0900 Subject: [PATCH 13/15] Block support: Preserve aria-label value in comment delimiter (#69002) Co-authored-by: t-hamano Co-authored-by: Mamaduka Co-authored-by: fabiankaegy --- packages/block-editor/src/hooks/aria-label.js | 11 ++-- .../parser/apply-built-in-validation-fixes.js | 18 +++++-- .../blocks/src/api/parser/fix-aria-label.js | 51 +++++++++++++++++++ packages/blocks/src/api/parser/test/index.js | 33 ++++++++++++ 4 files changed, 102 insertions(+), 11 deletions(-) create mode 100644 packages/blocks/src/api/parser/fix-aria-label.js diff --git a/packages/block-editor/src/hooks/aria-label.js b/packages/block-editor/src/hooks/aria-label.js index 7f93aa4ff8c8b..89de261a16938 100644 --- a/packages/block-editor/src/hooks/aria-label.js +++ b/packages/block-editor/src/hooks/aria-label.js @@ -4,13 +4,6 @@ import { addFilter } from '@wordpress/hooks'; import { hasBlockSupport } from '@wordpress/blocks'; -const ARIA_LABEL_SCHEMA = { - type: 'string', - source: 'attribute', - attribute: 'aria-label', - selector: '*', -}; - /** * Filters registered block settings, extending attributes with ariaLabel using aria-label * of the first node. @@ -28,7 +21,9 @@ export function addAttribute( settings ) { // Gracefully handle if settings.attributes is undefined. settings.attributes = { ...settings.attributes, - ariaLabel: ARIA_LABEL_SCHEMA, + ariaLabel: { + type: 'string', + }, }; } diff --git a/packages/blocks/src/api/parser/apply-built-in-validation-fixes.js b/packages/blocks/src/api/parser/apply-built-in-validation-fixes.js index 13dbb1e6825c9..52d6583265e6b 100644 --- a/packages/blocks/src/api/parser/apply-built-in-validation-fixes.js +++ b/packages/blocks/src/api/parser/apply-built-in-validation-fixes.js @@ -2,6 +2,7 @@ * Internal dependencies */ import { fixCustomClassname } from './fix-custom-classname'; +import { fixAriaLabel } from './fix-aria-label'; /** * Attempts to fix block invalidation by applying build-in validation fixes @@ -15,11 +16,22 @@ import { fixCustomClassname } from './fix-custom-classname'; * @return {WPBlock} Fixed block object */ export function applyBuiltInValidationFixes( block, blockType ) { - const updatedBlockAttributes = fixCustomClassname( - block.attributes, + const { attributes, originalContent } = block; + let updatedBlockAttributes = attributes; + + // Fix block invalidation for className attribute. + updatedBlockAttributes = fixCustomClassname( + attributes, + blockType, + originalContent + ); + // Fix block invalidation for ariaLabel attribute. + updatedBlockAttributes = fixAriaLabel( + updatedBlockAttributes, blockType, - block.originalContent + originalContent ); + return { ...block, attributes: updatedBlockAttributes, diff --git a/packages/blocks/src/api/parser/fix-aria-label.js b/packages/blocks/src/api/parser/fix-aria-label.js new file mode 100644 index 0000000000000..79fa30c713da2 --- /dev/null +++ b/packages/blocks/src/api/parser/fix-aria-label.js @@ -0,0 +1,51 @@ +/** + * Internal dependencies + */ +import { hasBlockSupport } from '../registration'; +import { parseWithAttributeSchema } from './get-block-attributes'; + +const ARIA_LABEL_ATTR_SCHEMA = { + type: 'string', + source: 'attribute', + selector: '[data-aria-label] > *', + attribute: 'aria-label', +}; + +/** + * Given an HTML string, returns the aria-label attribute assigned to + * the root element in the markup. + * + * @param {string} innerHTML Markup string from which to extract the aria-label. + * + * @return {string} The aria-label assigned to the root element. + */ +export function getHTMLRootElementAriaLabel( innerHTML ) { + const parsed = parseWithAttributeSchema( + `
${ innerHTML }
`, + ARIA_LABEL_ATTR_SCHEMA + ); + return parsed; +} + +/** + * Given a parsed set of block attributes, if the block supports ariaLabel + * and an aria-label attribute is found, the aria-label attribute is assigned + * to the block attributes. + * + * @param {Object} blockAttributes Original block attributes. + * @param {Object} blockType Block type settings. + * @param {string} innerHTML Original block markup. + * + * @return {Object} Filtered block attributes. + */ +export function fixAriaLabel( blockAttributes, blockType, innerHTML ) { + if ( ! hasBlockSupport( blockType, 'ariaLabel', false ) ) { + return blockAttributes; + } + const modifiedBlockAttributes = { ...blockAttributes }; + const ariaLabel = getHTMLRootElementAriaLabel( innerHTML ); + if ( ariaLabel ) { + modifiedBlockAttributes.ariaLabel = ariaLabel; + } + return modifiedBlockAttributes; +} diff --git a/packages/blocks/src/api/parser/test/index.js b/packages/blocks/src/api/parser/test/index.js index 42923a7d3eeb3..452fca329af76 100644 --- a/packages/blocks/src/api/parser/test/index.js +++ b/packages/blocks/src/api/parser/test/index.js @@ -82,6 +82,39 @@ describe( 'block parser', () => { } ); } ); + it( 'should apply aria-label block validation fixes', () => { + registerBlockType( 'core/test-block', { + ...defaultBlockSettings, + attributes: { + fruit: { + type: 'string', + source: 'text', + selector: 'div', + }, + }, + supports: { + ariaLabel: true, + }, + save: ( { attributes } ) => ( +
+ { attributes.fruit } +
+ ), + } ); + + const block = parseRawBlock( { + blockName: 'core/test-block', + innerHTML: '
Bananas
', + attrs: { fruit: 'Bananas' }, + } ); + + expect( block.name ).toEqual( 'core/test-block' ); + expect( block.attributes ).toEqual( { + fruit: 'Bananas', + ariaLabel: 'custom-label', + } ); + } ); + it( 'should create the requested block if it exists', () => { registerBlockType( 'core/test-block', defaultBlockSettings ); From edbd36057d3d25b7140af9e90a2adcca02a9201c Mon Sep 17 00:00:00 2001 From: Gulamdastgir-Momin <156418087+Gulamdastgir-Momin@users.noreply.github.com> Date: Tue, 4 Feb 2025 07:43:16 +0530 Subject: [PATCH 14/15] Added discord in social links. (#68848) * Added discord in social links. * Remove separator color fixtures. * Restore separator color fixture. * Added svg version. Co-authored-by: Gulamdastgir-Momin Co-authored-by: t-hamano Co-authored-by: mrfoxtalbot Co-authored-by: donalirl --- .../block-library/src/social-link/icons/discord.js | 10 ++++++++++ packages/block-library/src/social-link/icons/index.js | 1 + packages/block-library/src/social-link/index.php | 4 ++++ .../src/social-link/socials-with-bg.scss | 5 +++++ .../src/social-link/socials-without-bg.scss | 4 ++++ packages/block-library/src/social-link/variations.js | 7 +++++++ .../fixtures/blocks/core__social-link-discord.html | 1 + .../fixtures/blocks/core__social-link-discord.json | 11 +++++++++++ .../blocks/core__social-link-discord.parsed.json | 11 +++++++++++ .../blocks/core__social-link-discord.serialized.html | 1 + 10 files changed, 55 insertions(+) create mode 100644 packages/block-library/src/social-link/icons/discord.js create mode 100644 test/integration/fixtures/blocks/core__social-link-discord.html create mode 100644 test/integration/fixtures/blocks/core__social-link-discord.json create mode 100644 test/integration/fixtures/blocks/core__social-link-discord.parsed.json create mode 100644 test/integration/fixtures/blocks/core__social-link-discord.serialized.html diff --git a/packages/block-library/src/social-link/icons/discord.js b/packages/block-library/src/social-link/icons/discord.js new file mode 100644 index 0000000000000..6cb6165515369 --- /dev/null +++ b/packages/block-library/src/social-link/icons/discord.js @@ -0,0 +1,10 @@ +/** + * WordPress dependencies + */ +import { Path, SVG } from '@wordpress/primitives'; + +export const DiscordIcon = () => ( + + + +); diff --git a/packages/block-library/src/social-link/icons/index.js b/packages/block-library/src/social-link/icons/index.js index 422ff6f02dd20..bcc1976a7efb0 100644 --- a/packages/block-library/src/social-link/icons/index.js +++ b/packages/block-library/src/social-link/icons/index.js @@ -5,6 +5,7 @@ export * from './bluesky'; export * from './chain'; export * from './codepen'; export * from './deviantart'; +export * from './discord'; export * from './dribbble'; export * from './dropbox'; export * from './etsy'; diff --git a/packages/block-library/src/social-link/index.php b/packages/block-library/src/social-link/index.php index f241daff2a11a..9775f6dece5d7 100644 --- a/packages/block-library/src/social-link/index.php +++ b/packages/block-library/src/social-link/index.php @@ -169,6 +169,10 @@ function block_core_social_link_services( $service = '', $field = '' ) { 'name' => 'DeviantArt', 'icon' => '', ), + 'discord' => array( + 'name' => 'Discord', + 'icon' => '', + ), 'dribbble' => array( 'name' => 'Dribbble', 'icon' => '', diff --git a/packages/block-library/src/social-link/socials-with-bg.scss b/packages/block-library/src/social-link/socials-with-bg.scss index 35420fc624c0e..b51b718459739 100644 --- a/packages/block-library/src/social-link/socials-with-bg.scss +++ b/packages/block-library/src/social-link/socials-with-bg.scss @@ -33,6 +33,11 @@ color: #fff; } +.wp-social-link-discord { + background-color: #5865f2; + color: #fff; +} + .wp-social-link-dribbble { background-color: #e94c89; color: #fff; diff --git a/packages/block-library/src/social-link/socials-without-bg.scss b/packages/block-library/src/social-link/socials-without-bg.scss index 24538b29824b1..12b8620efb9f7 100644 --- a/packages/block-library/src/social-link/socials-without-bg.scss +++ b/packages/block-library/src/social-link/socials-without-bg.scss @@ -22,6 +22,10 @@ color: #02e49b; } +.wp-social-link-discord { + color: #5865f2; +} + .wp-social-link-dribbble { color: #e94c89; } diff --git a/packages/block-library/src/social-link/variations.js b/packages/block-library/src/social-link/variations.js index a97a396882d76..59fb469181449 100644 --- a/packages/block-library/src/social-link/variations.js +++ b/packages/block-library/src/social-link/variations.js @@ -9,6 +9,7 @@ import { ChainIcon, CodepenIcon, DeviantArtIcon, + DiscordIcon, DribbbleIcon, DropboxIcon, EtsyIcon, @@ -108,6 +109,12 @@ const variations = [ title: 'DeviantArt', icon: DeviantArtIcon, }, + { + name: 'discord', + attributes: { service: 'discord' }, + title: 'Discord', + icon: DiscordIcon, + }, { name: 'dribbble', attributes: { service: 'dribbble' }, diff --git a/test/integration/fixtures/blocks/core__social-link-discord.html b/test/integration/fixtures/blocks/core__social-link-discord.html new file mode 100644 index 0000000000000..e060dec0d1673 --- /dev/null +++ b/test/integration/fixtures/blocks/core__social-link-discord.html @@ -0,0 +1 @@ + diff --git a/test/integration/fixtures/blocks/core__social-link-discord.json b/test/integration/fixtures/blocks/core__social-link-discord.json new file mode 100644 index 0000000000000..fa5ce3ebf051d --- /dev/null +++ b/test/integration/fixtures/blocks/core__social-link-discord.json @@ -0,0 +1,11 @@ +[ + { + "name": "core/social-link", + "isValid": true, + "attributes": { + "url": "https://example.com/", + "service": "discord" + }, + "innerBlocks": [] + } +] diff --git a/test/integration/fixtures/blocks/core__social-link-discord.parsed.json b/test/integration/fixtures/blocks/core__social-link-discord.parsed.json new file mode 100644 index 0000000000000..7904c03b69d9d --- /dev/null +++ b/test/integration/fixtures/blocks/core__social-link-discord.parsed.json @@ -0,0 +1,11 @@ +[ + { + "blockName": "core/social-link-discord", + "attrs": { + "url": "https://example.com/" + }, + "innerBlocks": [], + "innerHTML": "", + "innerContent": [] + } +] diff --git a/test/integration/fixtures/blocks/core__social-link-discord.serialized.html b/test/integration/fixtures/blocks/core__social-link-discord.serialized.html new file mode 100644 index 0000000000000..c61b5ffcb46a5 --- /dev/null +++ b/test/integration/fixtures/blocks/core__social-link-discord.serialized.html @@ -0,0 +1 @@ + From 06379a3d51be05d10ebdfdc9029a94c5c5984306 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 4 Feb 2025 09:10:16 +0400 Subject: [PATCH 15/15] Query Block: Fix 'parents' argument validation (#68983) Co-authored-by: Mamaduka Co-authored-by: t-hamano --- backport-changelog/6.8/8245.md | 3 +++ lib/compat/wordpress-6.8/blocks.php | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 backport-changelog/6.8/8245.md diff --git a/backport-changelog/6.8/8245.md b/backport-changelog/6.8/8245.md new file mode 100644 index 0000000000000..ca9bc3588c5ce --- /dev/null +++ b/backport-changelog/6.8/8245.md @@ -0,0 +1,3 @@ +https://github.com/WordPress/wordpress-develop/pull/8245 + +* https://github.com/WordPress/gutenberg/pull/68983 diff --git a/lib/compat/wordpress-6.8/blocks.php b/lib/compat/wordpress-6.8/blocks.php index 90be78cd1457f..1d27215762fe4 100644 --- a/lib/compat/wordpress-6.8/blocks.php +++ b/lib/compat/wordpress-6.8/blocks.php @@ -217,3 +217,20 @@ function gutenberg_update_ignored_hooked_blocks_postmeta( $post ) { add_filter( 'rest_pre_insert_page', 'gutenberg_update_ignored_hooked_blocks_postmeta' ); add_filter( 'rest_pre_insert_post', 'gutenberg_update_ignored_hooked_blocks_postmeta' ); add_filter( 'rest_pre_insert_wp_block', 'gutenberg_update_ignored_hooked_blocks_postmeta' ); + +/** + * Update Query `parents` argument validation for hierarchical post types. + * A zero is a valid parent ID for hierarchical post types. Used to display top-level items. + * + * @param array $query The query vars. + * @param WP_Block $block Block instance. + * @return array The filtered query vars. + */ +function gutenberg_parents_query_vars_from_query_block( $query, $block ) { + if ( ! empty( $block->context['query']['parents'] ) && is_post_type_hierarchical( $query['post_type'] ) ) { + $query['post_parent__in'] = array_unique( array_map( 'intval', $block->context['query']['parents'] ) ); + } + + return $query; +} +add_filter( 'query_loop_block_query_vars', 'gutenberg_parents_query_vars_from_query_block', 10, 2 );