From f8897cc92bc820b359d00121a96897429c72423e Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Fri, 9 Feb 2024 17:08:54 +0100 Subject: [PATCH 01/16] Restore default border and focus style on image url input field. (#58505) * Restore default focus style on image url input field. * Make buttons use the 32 pixels compat size. * Remove image link settings top border. * Decrease left padding to grid-unit-15. * Restore the default border. * Revert all changes but the restored border. Co-authored-by: afercia Co-authored-by: carolinan Co-authored-by: t-hamano Co-authored-by: annezazu Co-authored-by: richtabor --- packages/block-editor/src/components/url-input/style.scss | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/block-editor/src/components/url-input/style.scss b/packages/block-editor/src/components/url-input/style.scss index 66f71e803595a8..f8d84ae43b8089 100644 --- a/packages/block-editor/src/components/url-input/style.scss +++ b/packages/block-editor/src/components/url-input/style.scss @@ -18,10 +18,6 @@ $input-size: 300px; margin-left: 0; margin-right: 0; - &:not(:focus) { - border-color: transparent; - } - /* Fonts smaller than 16px causes mobile safari to zoom. */ font-size: $mobile-text-min-font-size; @include break-small { From 8a16821123af477b39268260c8354be55fef8eb5 Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Mon, 12 Feb 2024 12:21:37 +0900 Subject: [PATCH 02/16] Spacer block: Fix `null` label in tooltip when horizontal layout (#58909) --- packages/block-library/src/spacer/editor.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/block-library/src/spacer/editor.scss b/packages/block-library/src/spacer/editor.scss index 9eb8c8b4b263ee..e0c700795c0870 100644 --- a/packages/block-library/src/spacer/editor.scss +++ b/packages/block-library/src/spacer/editor.scss @@ -42,5 +42,7 @@ &.resize-horizontal { margin-bottom: 0; + // Important is used to have higher specificity than the inline style set by re-resizable library. + height: 100% !important; } } From 781dc3bf9dcb908f4cfc30ce31d60562b1c56520 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Mon, 12 Feb 2024 18:21:15 +1100 Subject: [PATCH 03/16] Fix Spacer orientation when inside a block with default flex layout. (#58921) Co-authored-by: tellthemachines Co-authored-by: andrewserong Co-authored-by: t-hamano Co-authored-by: draganescu --- packages/block-library/src/spacer/edit.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/spacer/edit.js b/packages/block-library/src/spacer/edit.js index 11133732042d3f..d384f7997ec388 100644 --- a/packages/block-library/src/spacer/edit.js +++ b/packages/block-library/src/spacer/edit.js @@ -93,9 +93,14 @@ const SpacerEdit = ( { return editorSettings?.disableCustomSpacingSizes; } ); const { orientation } = context; - const { orientation: parentOrientation, type } = parentLayout || {}; + const { + orientation: parentOrientation, + type, + default: { type: defaultType } = {}, + } = parentLayout || {}; // Check if the spacer is inside a flex container. - const isFlexLayout = type === 'flex'; + const isFlexLayout = + type === 'flex' || ( ! type && defaultType === 'flex' ); // If the spacer is inside a flex container, it should either inherit the orientation // of the parent or use the flex default orientation. const inheritedOrientation = From 1adfe8d3cb3a9b5b66317ed293ef881ee1090b66 Mon Sep 17 00:00:00 2001 From: Ella <4710635+ellatrix@users.noreply.github.com> Date: Mon, 12 Feb 2024 12:05:17 +0100 Subject: [PATCH 04/16] Revert "Rich text: pad multiple spaces through en/em replacement (#56341)" (#58792) This reverts commit 53cae01b5de913779005bb7eaa5fd010555bf01c. Co-authored-by: ellatrix Co-authored-by: jeryj Co-authored-by: t-hamano Co-authored-by: dmsnell --- .../components/rich-text/use-input-rules.js | 32 ++----------------- test/e2e/specs/editor/blocks/links.spec.js | 4 +-- 2 files changed, 4 insertions(+), 32 deletions(-) diff --git a/packages/block-editor/src/components/rich-text/use-input-rules.js b/packages/block-editor/src/components/rich-text/use-input-rules.js index 37e61997f14986..ff871eb9363234 100644 --- a/packages/block-editor/src/components/rich-text/use-input-rules.js +++ b/packages/block-editor/src/components/rich-text/use-input-rules.js @@ -3,7 +3,7 @@ */ import { useRef } from '@wordpress/element'; import { useRefEffect } from '@wordpress/compose'; -import { insert, isCollapsed, toHTMLString } from '@wordpress/rich-text'; +import { insert, toHTMLString } from '@wordpress/rich-text'; import { getBlockTransforms, findTransform } from '@wordpress/blocks'; import { useDispatch } from '@wordpress/data'; @@ -47,34 +47,6 @@ function findSelection( blocks ) { return []; } -/** - * An input rule that replaces two spaces with an en space, and an en space - * followed by a space with an em space. - * - * @param {Object} value Value to replace spaces in. - * - * @return {Object} Value with spaces replaced. - */ -function replacePrecedingSpaces( value ) { - if ( ! isCollapsed( value ) ) { - return value; - } - - const { text, start } = value; - const lastTwoCharacters = text.slice( start - 2, start ); - - // Replace two spaces with an em space. - if ( lastTwoCharacters === ' ' ) { - return insert( value, '\u2002', start - 2, start ); - } - // Replace an en space followed by a space with an em space. - else if ( lastTwoCharacters === '\u2002 ' ) { - return insert( value, '\u2003', start - 2, start ); - } - - return value; -} - export function useInputRules( props ) { const { __unstableMarkLastChangeAsPersistent, @@ -155,7 +127,7 @@ export function useInputRules( props ) { return accumlator; }, - preventEventDiscovery( replacePrecedingSpaces( value ) ) + preventEventDiscovery( value ) ); if ( transformed !== value ) { diff --git a/test/e2e/specs/editor/blocks/links.spec.js b/test/e2e/specs/editor/blocks/links.spec.js index 0a95064032f832..d0689cabd7e6b0 100644 --- a/test/e2e/specs/editor/blocks/links.spec.js +++ b/test/e2e/specs/editor/blocks/links.spec.js @@ -1026,8 +1026,8 @@ test.describe( 'Links', () => { pageUtils, editor, } ) => { - const textToSelect = `\u2003\u2003 spaces\u2003 `; - const textWithWhitespace = `Text with leading and trailing spaces `; + const textToSelect = ` spaces `; + const textWithWhitespace = `Text with leading and trailing${ textToSelect }`; // Create a block with some text. await editor.insertBlock( { From 924b0f1c0aa095b38de19105ec7a38660289017a Mon Sep 17 00:00:00 2001 From: Ella <4710635+ellatrix@users.noreply.github.com> Date: Mon, 12 Feb 2024 13:04:39 +0100 Subject: [PATCH 05/16] Site editor: fix start patterns store selector (#58813) Unlinked contributors: bgardner. Co-authored-by: ellatrix Co-authored-by: youknowriad Co-authored-by: colorful-tones --- .../src/components/start-template-options/index.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/edit-site/src/components/start-template-options/index.js b/packages/edit-site/src/components/start-template-options/index.js index 771f380db05a3d..21e534499b8b5e 100644 --- a/packages/edit-site/src/components/start-template-options/index.js +++ b/packages/edit-site/src/components/start-template-options/index.js @@ -4,10 +4,7 @@ import { Modal, Flex, FlexItem, Button } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { useState, useMemo } from '@wordpress/element'; -import { - __experimentalBlockPatternsList as BlockPatternsList, - store as blockEditorStore, -} from '@wordpress/block-editor'; +import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor'; import { useSelect } from '@wordpress/data'; import { useAsyncList } from '@wordpress/compose'; import { store as preferencesStore } from '@wordpress/preferences'; @@ -42,14 +39,13 @@ function useFallbackTemplateContent( slug, isCustom = false ) { function useStartPatterns( fallbackContent ) { const { slug, patterns } = useSelect( ( select ) => { const { getEditedPostType, getEditedPostId } = select( editSiteStore ); - const { getEntityRecord } = select( coreStore ); + const { getEntityRecord, getBlockPatterns } = select( coreStore ); const postId = getEditedPostId(); const postType = getEditedPostType(); const record = getEntityRecord( 'postType', postType, postId ); - const { getSettings } = select( blockEditorStore ); return { slug: record.slug, - patterns: getSettings().__experimentalBlockPatterns, + patterns: getBlockPatterns(), }; }, [] ); From 5f03c585eff9557c1f290400f50bdda794556ddc Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Mon, 12 Feb 2024 09:16:44 -0600 Subject: [PATCH 06/16] Fix incorrect useAnchor positioning when switching from virtual to rich text elements (#58900) When creating a link or inline text color, we start with a virtual element and then after creating the link/adding a color, it switches from a virtual to rich text element ( or ). We want to recompute that we've changed elements and reanchor appropriately when this happens. Also, useAnchor was adding focus and selectionChange events that were only used by a previous version of the link control UX where the link popover would show based on the caret position. If the caret was within the link, we would show the link popover. This is no longer the case, so we can remove these event listeners. --- packages/format-library/src/link/inline.js | 22 +---------- .../format-library/src/text-color/index.js | 1 + .../format-library/src/text-color/inline.js | 14 +------ .../rich-text/src/component/use-anchor.js | 38 +++++++------------ 4 files changed, 17 insertions(+), 58 deletions(-) diff --git a/packages/format-library/src/link/inline.js b/packages/format-library/src/link/inline.js index 7d0594981c290c..b01f37e9657bbb 100644 --- a/packages/format-library/src/link/inline.js +++ b/packages/format-library/src/link/inline.js @@ -21,7 +21,6 @@ import { import { __experimentalLinkControl as LinkControl, store as blockEditorStore, - useCachedTruthy, } from '@wordpress/block-editor'; import { useSelect } from '@wordpress/data'; @@ -195,28 +194,9 @@ function InlineLinkUI( { const popoverAnchor = useAnchor( { editableContentElement: contentRef.current, - settings, + settings: { ...settings, isActive }, } ); - // As you change the link by interacting with the Link UI - // the return value of document.getSelection jumps to the field you're editing, - // not the highlighted text. Given that useAnchor uses document.getSelection, - // it will return null, since it can't find the element within the Link UI. - // This caches the last truthy value of the selection anchor reference. - // This ensures the Popover is positioned correctly on initial submission of the link. - const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() ); - - // If the link is not active (i.e. it is a new link) then we need to - // override the getBoundingClientRect method on the anchor element - // to return the cached value of the selection represented by the text - // that the user selected to be linked. - // If the link is active (i.e. it is an existing link) then we allow - // the default behaviour of the popover anchor to be used. This will get - // the anchor based on the `` element in the rich text. - if ( ! isActive ) { - popoverAnchor.getBoundingClientRect = () => cachedRect; - } - async function handleCreate( pageTitle ) { const page = await createPageEntity( { title: pageTitle, diff --git a/packages/format-library/src/text-color/index.js b/packages/format-library/src/text-color/index.js index 8a28cb69549cdc..464c2eec7c065c 100644 --- a/packages/format-library/src/text-color/index.js +++ b/packages/format-library/src/text-color/index.js @@ -120,6 +120,7 @@ function TextColorEdit( { value={ value } onChange={ onChange } contentRef={ contentRef } + isActive={ isActive } /> ) } diff --git a/packages/format-library/src/text-color/inline.js b/packages/format-library/src/text-color/inline.js index 98ced2cca01e29..8bd4ae33c78443 100644 --- a/packages/format-library/src/text-color/inline.js +++ b/packages/format-library/src/text-color/inline.js @@ -15,7 +15,6 @@ import { getColorObjectByColorValue, getColorObjectByAttributeValues, store as blockEditorStore, - useCachedTruthy, } from '@wordpress/block-editor'; import { Popover, @@ -147,22 +146,13 @@ export default function InlineColorUI( { onChange, onClose, contentRef, + isActive, } ) { const popoverAnchor = useAnchor( { editableContentElement: contentRef.current, - settings, + settings: { ...settings, isActive }, } ); - /* - As you change the text color by typing a HEX value into a field, - the return value of document.getSelection jumps to the field you're editing, - not the highlighted text. Given that useAnchor uses document.getSelection, - it will return null, since it can't find the element within the HEX input. - This caches the last truthy value of the selection anchor reference. - */ - const cachedRect = useCachedTruthy( popoverAnchor.getBoundingClientRect() ); - popoverAnchor.getBoundingClientRect = () => cachedRect; - return ( getAnchor( editableContentElement, tagName, className ) ); + const wasActive = usePrevious( isActive ); useLayoutEffect( () => { if ( ! editableContentElement ) return; const { ownerDocument } = editableContentElement; - function callback() { + if ( + editableContentElement === ownerDocument.activeElement || + // When a link is created, we need to attach the popover to the newly created anchor. + ( ! wasActive && isActive ) || + // Sometimes we're _removing_ an active anchor, such as the inline color popover. + // When we add the color, it switches from a virtual anchor to a `` element. + // When we _remove_ the color, it switches from a `` element to a virtual anchor. + ( wasActive && ! isActive ) + ) { setAnchor( getAnchor( editableContentElement, tagName, className ) ); } - - function attach() { - ownerDocument.addEventListener( 'selectionchange', callback ); - } - - function detach() { - ownerDocument.removeEventListener( 'selectionchange', callback ); - } - - if ( editableContentElement === ownerDocument.activeElement ) { - attach(); - } - - editableContentElement.addEventListener( 'focusin', attach ); - editableContentElement.addEventListener( 'focusout', detach ); - - return () => { - detach(); - - editableContentElement.removeEventListener( 'focusin', attach ); - editableContentElement.removeEventListener( 'focusout', detach ); - }; - }, [ editableContentElement, tagName, className ] ); + }, [ editableContentElement, tagName, className, isActive, wasActive ] ); return anchor; } From d1155e0023316cb78a1123267978d339b982447c Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Mon, 12 Feb 2024 09:17:57 -0600 Subject: [PATCH 07/16] Close link preview if collapsed selection when creating link (#58896) Return caret to after the link boundary so typing can continue if no text is selected when creating a link. --- packages/format-library/src/link/index.js | 13 +------ packages/format-library/src/link/inline.js | 44 ++++++++++++++++------ 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/packages/format-library/src/link/index.js b/packages/format-library/src/link/index.js index eb4beebce3f253..61b6f974cdce3a 100644 --- a/packages/format-library/src/link/index.js +++ b/packages/format-library/src/link/index.js @@ -48,17 +48,6 @@ function Edit( { return; } - // Close the Link popover if there is no active selection - // after the link was added - this can happen if the user - // adds a link without any text selected. - // We assume that if there is no active selection after - // link insertion there are no active formats. - if ( ! value.activeFormats ) { - editableContentElement.focus(); - setAddingLink( false ); - return; - } - function handleClick( event ) { // There is a situation whereby there is an existing link in the rich text // and the user clicks on the leftmost edge of that link and fails to activate @@ -78,7 +67,7 @@ function Edit( { return () => { editableContentElement.removeEventListener( 'click', handleClick ); }; - }, [ contentRef, isActive, addingLink, value ] ); + }, [ contentRef, isActive ] ); function addLink( target ) { const text = getTextContent( slice( value ) ); diff --git a/packages/format-library/src/link/inline.js b/packages/format-library/src/link/inline.js index b01f37e9657bbb..1e48d0c8fa47f0 100644 --- a/packages/format-library/src/link/inline.js +++ b/packages/format-library/src/link/inline.js @@ -22,7 +22,7 @@ import { __experimentalLinkControl as LinkControl, store as blockEditorStore, } from '@wordpress/block-editor'; -import { useSelect } from '@wordpress/data'; +import { useDispatch, useSelect } from '@wordpress/data'; /** * Internal dependencies @@ -52,15 +52,22 @@ function InlineLinkUI( { // Get the text content minus any HTML tags. const richTextText = richLinkTextValue.text; - const { createPageEntity, userCanCreatePages } = useSelect( ( select ) => { - const { getSettings } = select( blockEditorStore ); - const _settings = getSettings(); - - return { - createPageEntity: _settings.__experimentalCreatePageEntity, - userCanCreatePages: _settings.__experimentalUserCanCreatePages, - }; - }, [] ); + const { selectionChange } = useDispatch( blockEditorStore ); + + const { createPageEntity, userCanCreatePages, selectionStart } = useSelect( + ( select ) => { + const { getSettings, getSelectionStart } = + select( blockEditorStore ); + const _settings = getSettings(); + + return { + createPageEntity: _settings.__experimentalCreatePageEntity, + userCanCreatePages: _settings.__experimentalUserCanCreatePages, + selectionStart: getSelectionStart(), + }; + }, + [] + ); const linkValue = useMemo( () => ( { @@ -122,8 +129,23 @@ function InlineLinkUI( { inserted, linkFormat, value.start, - value.end + newText.length + value.start + newText.length ); + + onChange( newValue ); + + // Close the Link UI. + stopAddingLink(); + + // Move the selection to the end of the inserted link outside of the format boundary + // so the user can continue typing after the link. + selectionChange( { + clientId: selectionStart.clientId, + identifier: selectionStart.attributeKey, + start: value.start + newText.length + 1, + } ); + + return; } else if ( newText === richTextText ) { newValue = applyFormat( value, linkFormat ); } else { From f7e9fdf691bfb4a22efeda81090aa4b48d1bf24b Mon Sep 17 00:00:00 2001 From: David Arenas Date: Mon, 12 Feb 2024 16:28:06 +0100 Subject: [PATCH 08/16] Pagination Numbers: Add `data-wp-key` to pagination numbers if enhanced pagination is enabled (#58189) * Add `data-wp-key` to pagination numbers * Use tag index as the `data-wp-key` value Co-authored-by: DAreRodz Co-authored-by: SantosGuillamot Co-authored-by: c4rl0sbr4v0 --- .../src/query-pagination-numbers/index.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/block-library/src/query-pagination-numbers/index.php b/packages/block-library/src/query-pagination-numbers/index.php index 2f9370751f6d25..e6f8b461110407 100644 --- a/packages/block-library/src/query-pagination-numbers/index.php +++ b/packages/block-library/src/query-pagination-numbers/index.php @@ -91,14 +91,17 @@ function render_block_core_query_pagination_numbers( $attributes, $content, $blo } if ( $enhanced_pagination ) { - $p = new WP_HTML_Tag_Processor( $content ); + $p = new WP_HTML_Tag_Processor( $content ); + $tag_index = 0; while ( $p->next_tag( - array( - 'tag_name' => 'a', - 'class_name' => 'page-numbers', - ) + array( 'class_name' => 'page-numbers' ) ) ) { - $p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' ); + if ( null === $p->get_attribute( 'data-wp-key' ) ) { + $p->set_attribute( 'data-wp-key', 'index-' . $tag_index++ ); + } + if ( 'A' === $p->get_tag() ) { + $p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' ); + } } $content = $p->get_updated_html(); } From 50cd70c9a1bef342c394e4a52b7b2ec543ff539a Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 12 Feb 2024 16:38:39 +0100 Subject: [PATCH 09/16] Editor: Remove the 'all' rendering mode (#58935) Co-authored-by: youknowriad Co-authored-by: ellatrix --- docs/reference-guides/data/data-core-editor.md | 2 +- packages/edit-post/src/editor.js | 5 +---- packages/edit-post/src/index.js | 10 ++-------- packages/edit-post/src/store/selectors.js | 2 +- .../block-editor/use-site-editor-settings.js | 4 +++- packages/editor/src/components/editor-canvas/index.js | 2 +- packages/editor/src/store/actions.js | 2 +- packages/editor/src/store/reducer.js | 2 +- 8 files changed, 11 insertions(+), 18 deletions(-) diff --git a/docs/reference-guides/data/data-core-editor.md b/docs/reference-guides/data/data-core-editor.md index 5cae4759654018..72083022041643 100644 --- a/docs/reference-guides/data/data-core-editor.md +++ b/docs/reference-guides/data/data-core-editor.md @@ -1409,7 +1409,7 @@ Returns an action used to set the rendering mode of the post editor. We support _Parameters_ -- _mode_ `string`: Mode (one of 'post-only', 'template-locked' or 'all'). +- _mode_ `string`: Mode (one of 'post-only' or 'template-locked'). ### setTemplateValidity diff --git a/packages/edit-post/src/editor.js b/packages/edit-post/src/editor.js index 7c572c4a91fcf2..7b961098fc3daa 100644 --- a/packages/edit-post/src/editor.js +++ b/packages/edit-post/src/editor.js @@ -89,15 +89,13 @@ function Editor( { ); const { updatePreferredStyleVariations } = useDispatch( editPostStore ); - const defaultRenderingMode = - currentPost.postType === 'wp_template' ? 'all' : 'post-only'; const editorSettings = useMemo( () => ( { ...settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord, - defaultRenderingMode, + defaultRenderingMode: 'post-only', __experimentalPreferredStyleVariations: { value: preferredStyleVariations, onChange: updatePreferredStyleVariations, @@ -111,7 +109,6 @@ function Editor( { updatePreferredStyleVariations, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord, - defaultRenderingMode, ] ); diff --git a/packages/edit-post/src/index.js b/packages/edit-post/src/index.js index 78c79227c9d897..08bc7c5aa7002c 100644 --- a/packages/edit-post/src/index.js +++ b/packages/edit-post/src/index.js @@ -103,10 +103,7 @@ export function initializeEditor( 'blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', ( canInsert, blockType ) => { - if ( - select( editorStore ).getRenderingMode() === 'post-only' && - blockType.name === 'core/template-part' - ) { + if ( blockType.name === 'core/template-part' ) { return false; } return canInsert; @@ -128,10 +125,7 @@ export function initializeEditor( rootClientId, { getBlockParentsByBlockName } ) => { - if ( - select( editorStore ).getRenderingMode() === 'post-only' && - blockType.name === 'core/post-content' - ) { + if ( blockType.name === 'core/post-content' ) { return ( getBlockParentsByBlockName( rootClientId, 'core/query' ) .length > 0 diff --git a/packages/edit-post/src/store/selectors.js b/packages/edit-post/src/store/selectors.js index 1a39a516da8f52..f5b4a27e158ea0 100644 --- a/packages/edit-post/src/store/selectors.js +++ b/packages/edit-post/src/store/selectors.js @@ -556,7 +556,7 @@ export const isEditingTemplate = createRegistrySelector( ( select ) => () => { since: '6.5', alternative: `select( 'core/editor' ).getRenderingMode`, } ); - return select( editorStore ).getRenderingMode() !== 'post-only'; + return select( editorStore ).getCurrentPostType() !== 'post-only'; } ); /** diff --git a/packages/edit-site/src/components/block-editor/use-site-editor-settings.js b/packages/edit-site/src/components/block-editor/use-site-editor-settings.js index a99ea627268950..0c7dbe8ec3d04f 100644 --- a/packages/edit-site/src/components/block-editor/use-site-editor-settings.js +++ b/packages/edit-site/src/components/block-editor/use-site-editor-settings.js @@ -144,7 +144,9 @@ export function useSpecificEditorSettings() { [] ); const archiveLabels = useArchiveLabel( templateSlug ); - const defaultRenderingMode = postWithTemplate ? 'template-locked' : 'all'; + const defaultRenderingMode = postWithTemplate + ? 'template-locked' + : 'post-only'; const onNavigateToPreviousEntityRecord = useNavigateToPreviousEntityRecord(); const defaultEditorSettings = useMemo( () => { diff --git a/packages/editor/src/components/editor-canvas/index.js b/packages/editor/src/components/editor-canvas/index.js index 489694bb8adfd5..f011f285644c0e 100644 --- a/packages/editor/src/components/editor-canvas/index.js +++ b/packages/editor/src/components/editor-canvas/index.js @@ -110,7 +110,7 @@ function EditorCanvas( { if ( postTypeSlug === 'wp_block' ) { _wrapperBlockName = 'core/block'; - } else if ( ! _renderingMode === 'post-only' ) { + } else if ( _renderingMode === 'post-only' ) { _wrapperBlockName = 'core/post-content'; } diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js index 8d716a04346dae..4c0f1078fde655 100644 --- a/packages/editor/src/store/actions.js +++ b/packages/editor/src/store/actions.js @@ -585,7 +585,7 @@ export function updateEditorSettings( settings ) { * - `post-only`: This mode extracts the post blocks from the template and renders only those. The idea is to allow the user to edit the post/page in isolation without the wrapping template. * - `template-locked`: This mode renders both the template and the post blocks but the template blocks are locked and can't be edited. The post blocks are editable. * - * @param {string} mode Mode (one of 'post-only', 'template-locked' or 'all'). + * @param {string} mode Mode (one of 'post-only' or 'template-locked'). */ export const setRenderingMode = ( mode ) => diff --git a/packages/editor/src/store/reducer.js b/packages/editor/src/store/reducer.js index 978a5c8697410a..b2ae6b5224b14c 100644 --- a/packages/editor/src/store/reducer.js +++ b/packages/editor/src/store/reducer.js @@ -266,7 +266,7 @@ export function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) { return state; } -export function renderingMode( state = 'all', action ) { +export function renderingMode( state = 'post-only', action ) { switch ( action.type ) { case 'SET_RENDERING_MODE': return action.mode; From 72a22e549c1db41c8ed33201587cc5ac73557741 Mon Sep 17 00:00:00 2001 From: Mario Santos <34552881+SantosGuillamot@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:40:30 +0100 Subject: [PATCH 10/16] Block Bindings: lock editing of blocks by default (#58787) * Lock editing by default when bindings exist * Use default in post meta source * Set `lockEditing` to false in pattern overrides * Move default value to reducer * Use `_x` for sources translations * Add context to translations --- .../block-editor/src/hooks/use-bindings-attributes.js | 2 +- packages/block-editor/src/store/reducer.js | 2 +- packages/block-library/src/button/edit.js | 2 +- packages/block-library/src/image/edit.js | 2 +- packages/block-library/src/image/image.js | 6 +++--- packages/editor/src/bindings/index.js | 2 ++ packages/editor/src/bindings/pattern-overrides.js | 11 +++++++++++ packages/editor/src/bindings/post-meta.js | 5 ++--- 8 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 packages/editor/src/bindings/pattern-overrides.js diff --git a/packages/block-editor/src/hooks/use-bindings-attributes.js b/packages/block-editor/src/hooks/use-bindings-attributes.js index a1873143c294af..75f337cff97957 100644 --- a/packages/block-editor/src/hooks/use-bindings-attributes.js +++ b/packages/block-editor/src/hooks/use-bindings-attributes.js @@ -46,7 +46,7 @@ const createEditFunctionWithBindingsAttribute = () => settings.source ); - if ( source ) { + if ( source && source.useSource ) { // Second argument (`updateMetaValue`) will be used to update the value in the future. const { placeholder, diff --git a/packages/block-editor/src/store/reducer.js b/packages/block-editor/src/store/reducer.js index d4755169c53e56..0be421b757bce1 100644 --- a/packages/block-editor/src/store/reducer.js +++ b/packages/block-editor/src/store/reducer.js @@ -2057,7 +2057,7 @@ function blockBindingsSources( state = {}, action ) { [ action.sourceName ]: { label: action.sourceLabel, useSource: action.useSource, - lockAttributesEditing: action.lockAttributesEditing, + lockAttributesEditing: action.lockAttributesEditing ?? true, }, }; } diff --git a/packages/block-library/src/button/edit.js b/packages/block-library/src/button/edit.js index c3a2aff1bd0d9f..e01898ca00dec4 100644 --- a/packages/block-library/src/button/edit.js +++ b/packages/block-library/src/button/edit.js @@ -246,7 +246,7 @@ function ButtonEdit( props ) { lockUrlControls: !! metadata?.bindings?.url && getBlockBindingsSource( metadata?.bindings?.url?.source ) - ?.lockAttributesEditing === true, + ?.lockAttributesEditing, }; }, [ isSelected ] diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 63b99460b386af..61d023e4e580a1 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -349,7 +349,7 @@ export function ImageEdit( { lockUrlControls: !! metadata?.bindings?.url && getBlockBindingsSource( metadata?.bindings?.url?.source ) - ?.lockAttributesEditing === true, + ?.lockAttributesEditing, }; }, [ isSingleSelected ] diff --git a/packages/block-library/src/image/image.js b/packages/block-library/src/image/image.js index 8c911fad726aed..f551d8df007a8e 100644 --- a/packages/block-library/src/image/image.js +++ b/packages/block-library/src/image/image.js @@ -427,7 +427,7 @@ export default function Image( { lockUrlControls: !! urlBinding && getBlockBindingsSource( urlBinding?.source ) - ?.lockAttributesEditing === true, + ?.lockAttributesEditing, lockHrefControls: // Disable editing the link of the URL if the image is inside a pattern instance. // This is a temporary solution until we support overriding the link on the frontend. @@ -435,11 +435,11 @@ export default function Image( { lockAltControls: !! altBinding && getBlockBindingsSource( altBinding?.source ) - ?.lockAttributesEditing === true, + ?.lockAttributesEditing, lockTitleControls: !! titleBinding && getBlockBindingsSource( titleBinding?.source ) - ?.lockAttributesEditing === true, + ?.lockAttributesEditing, }; }, [ clientId, isSingleSelected, metadata?.bindings ] diff --git a/packages/editor/src/bindings/index.js b/packages/editor/src/bindings/index.js index 8a883e8904a71b..ff0516902e321c 100644 --- a/packages/editor/src/bindings/index.js +++ b/packages/editor/src/bindings/index.js @@ -7,7 +7,9 @@ import { dispatch } from '@wordpress/data'; * Internal dependencies */ import { unlock } from '../lock-unlock'; +import patternOverrides from './pattern-overrides'; import postMeta from './post-meta'; const { registerBlockBindingsSource } = unlock( dispatch( blockEditorStore ) ); +registerBlockBindingsSource( patternOverrides ); registerBlockBindingsSource( postMeta ); diff --git a/packages/editor/src/bindings/pattern-overrides.js b/packages/editor/src/bindings/pattern-overrides.js new file mode 100644 index 00000000000000..5f7f475a649a3e --- /dev/null +++ b/packages/editor/src/bindings/pattern-overrides.js @@ -0,0 +1,11 @@ +/** + * WordPress dependencies + */ +import { _x } from '@wordpress/i18n'; + +export default { + name: 'core/pattern-overrides', + label: _x( 'Pattern Overrides', 'block bindings source' ), + useSource: null, + lockAttributesEditing: false, +}; diff --git a/packages/editor/src/bindings/post-meta.js b/packages/editor/src/bindings/post-meta.js index 091491b2ed00c7..a9a00599b68037 100644 --- a/packages/editor/src/bindings/post-meta.js +++ b/packages/editor/src/bindings/post-meta.js @@ -3,7 +3,7 @@ */ import { useEntityProp } from '@wordpress/core-data'; import { useSelect } from '@wordpress/data'; -import { __ } from '@wordpress/i18n'; +import { _x } from '@wordpress/i18n'; /** * Internal dependencies */ @@ -11,7 +11,7 @@ import { store as editorStore } from '../store'; export default { name: 'core/post-meta', - label: __( 'Post Meta' ), + label: _x( 'Post Meta', 'block bindings source' ), useSource( props, sourceAttributes ) { const { getCurrentPostType } = useSelect( editorStore ); const { context } = props; @@ -38,5 +38,4 @@ export default { useValue: [ metaValue, updateMetaValue ], }; }, - lockAttributesEditing: true, }; From 5ccaa81398fcd932dce8e55be7a06b9b7dc80a39 Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Tue, 13 Feb 2024 01:13:51 +0900 Subject: [PATCH 11/16] Font Library: Show error message when no fonts found to install (#58914) Co-authored-by: t-hamano Co-authored-by: matiasbenedetto Co-authored-by: okmttdhr --- .../global-styles/font-library-modal/context.js | 9 --------- .../font-library-modal/tab-panel-layout.js | 10 +++++++++- .../global-styles/font-library-modal/upload-fonts.js | 6 ++++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/context.js b/packages/edit-site/src/components/global-styles/font-library-modal/context.js index 2b9efd2ddccd69..04eabb149f5f4e 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/context.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/context.js @@ -61,15 +61,6 @@ function FontLibraryProvider( { children } ) { setRefreshKey( Date.now() ); }; - // Reset notice on dismiss. - useEffect( () => { - if ( notice ) { - notice.onRemove = () => { - setNotice( null ); - }; - } - }, [ notice, setNotice ] ); - const { records: libraryPosts = [], isResolving: isResolvingLibrary, diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js b/packages/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js index 7250e0a745ce50..c959a5373190ec 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/tab-panel-layout.js @@ -1,6 +1,7 @@ /** * WordPress dependencies */ +import { useContext } from '@wordpress/element'; import { __experimentalText as Text, __experimentalHeading as Heading, @@ -14,6 +15,11 @@ import { import { chevronLeft } from '@wordpress/icons'; import { __ } from '@wordpress/i18n'; +/** + * Internal dependencies + */ +import { FontLibraryContext } from './context'; + function TabPanelLayout( { title, description, @@ -22,6 +28,8 @@ function TabPanelLayout( { children, footer, } ) { + const { setNotice } = useContext( FontLibraryContext ); + return (
@@ -53,7 +61,7 @@ function TabPanelLayout( { setNotice( null ) } > { notice.message } diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js b/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js index c956b0d55e6918..a40534861ae966 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/upload-fonts.js @@ -63,6 +63,12 @@ function UploadFonts() { } ); if ( allowedFiles.length > 0 ) { loadFiles( allowedFiles ); + } else { + setNotice( { + type: 'error', + message: __( 'No fonts found to install.' ), + } ); + setIsUploading( false ); } }; From a56d511560e052754663286692bfa9c6d8c0aa1d Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Mon, 12 Feb 2024 18:02:51 +0100 Subject: [PATCH 12/16] Clean up link control CSS. (#58934) --- .../block-editor/src/components/link-control/style.scss | 7 ------- 1 file changed, 7 deletions(-) diff --git a/packages/block-editor/src/components/link-control/style.scss b/packages/block-editor/src/components/link-control/style.scss index 96820aee356d3e..425df96ab31fa6 100644 --- a/packages/block-editor/src/components/link-control/style.scss +++ b/packages/block-editor/src/components/link-control/style.scss @@ -340,13 +340,6 @@ $block-editor-link-control-number-of-actions: 1; } } -.block-editor-link-control__drawer { - display: flex; // allow for ordering. - order: 30; - flex-direction: column; - flex-basis: 100%; // occupy full width. -} - // Inner div required to avoid padding/margin // causing janky animation. .block-editor-link-control__drawer-inner { From 87c120a634e70839694ea1d24221e2cb3a21591a Mon Sep 17 00:00:00 2001 From: Mario Santos <34552881+SantosGuillamot@users.noreply.github.com> Date: Mon, 12 Feb 2024 20:46:45 +0100 Subject: [PATCH 13/16] Use `data_wp_context` helper in core blocks and remove `data-wp-interactive` object (#58943) * Update file block * Update image block * Update navigation block * Update query block * WIP: Update form block * Use boolean instead of string in `$open_by_default` variable * Don't use `data-wp-interactive` object in search block * Remove unnecessary quotes * Adapt query block unit test Co-authored-by: SantosGuillamot Co-authored-by: c4rl0sbr4v0 --- packages/block-library/src/file/index.php | 2 +- packages/block-library/src/image/index.php | 4 ++-- .../block-library/src/navigation/index.php | 12 +++++------ packages/block-library/src/query/index.php | 2 +- packages/block-library/src/search/index.php | 20 +++++++++++++------ phpunit/blocks/render-query-test.php | 2 +- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/packages/block-library/src/file/index.php b/packages/block-library/src/file/index.php index b2e7f86dcc7a3c..ba0343ae6b25c6 100644 --- a/packages/block-library/src/file/index.php +++ b/packages/block-library/src/file/index.php @@ -53,7 +53,7 @@ static function ( $matches ) { $processor = new WP_HTML_Tag_Processor( $content ); $processor->next_tag(); - $processor->set_attribute( 'data-wp-interactive', '{"namespace":"core/file"}' ); + $processor->set_attribute( 'data-wp-interactive', 'core/file' ); $processor->next_tag( 'object' ); $processor->set_attribute( 'data-wp-bind--hidden', '!state.hasPdfPreview' ); $processor->set_attribute( 'hidden', true ); diff --git a/packages/block-library/src/image/index.php b/packages/block-library/src/image/index.php index ab22133398c58b..0b75bf95a7d4ce 100644 --- a/packages/block-library/src/image/index.php +++ b/packages/block-library/src/image/index.php @@ -159,7 +159,7 @@ function block_core_image_render_lightbox( $block_content, $block ) { $figure_class_names = $p->get_attribute( 'class' ); $figure_styles = $p->get_attribute( 'style' ); $p->add_class( 'wp-lightbox-container' ); - $p->set_attribute( 'data-wp-interactive', '{"namespace":"core/image"}' ); + $p->set_attribute( 'data-wp-interactive', 'core/image' ); $p->set_attribute( 'data-wp-context', wp_json_encode( @@ -240,7 +240,7 @@ function block_core_image_print_lightbox_overlay() { echo << array(), 'type' => 'overlay', 'roleAttribute' => '', 'ariaLabel' => __( 'Menu' ), - ), - JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP + ) ); $nav_element_directives = ' - data-wp-interactive=\'{"namespace":"core/navigation"}\' - data-wp-context=\'' . $nav_element_context . '\' - '; + data-wp-interactive="core/navigation"' + . $nav_element_context; /* * When the navigation's 'overlayMenu' attribute is set to 'always', JavaScript @@ -780,7 +778,7 @@ function block_core_navigation_add_directives_to_submenu( $tags, $block_attribut ) ) ) { // Add directives to the parent `
  • `. - $tags->set_attribute( 'data-wp-interactive', '{ "namespace": "core/navigation" }' ); + $tags->set_attribute( 'data-wp-interactive', 'core/navigation' ); $tags->set_attribute( 'data-wp-context', '{ "submenuOpenedBy": {}, "type": "submenu" }' ); $tags->set_attribute( 'data-wp-watch', 'callbacks.initMenu' ); $tags->set_attribute( 'data-wp-on--focusout', 'actions.handleMenuFocusout' ); diff --git a/packages/block-library/src/query/index.php b/packages/block-library/src/query/index.php index 1a536dd3dcd98f..b6c34eb71d0703 100644 --- a/packages/block-library/src/query/index.php +++ b/packages/block-library/src/query/index.php @@ -49,7 +49,7 @@ function render_block_core_query( $attributes, $content, $block ) { $p = new WP_HTML_Tag_Processor( $content ); if ( $p->next_tag() ) { // Add the necessary directives. - $p->set_attribute( 'data-wp-interactive', '{"namespace":"core/query"}' ); + $p->set_attribute( 'data-wp-interactive', 'core/query' ); $p->set_attribute( 'data-wp-router-region', 'query-' . $attributes['queryId'] ); $p->set_attribute( 'data-wp-init', 'callbacks.setQueryRef' ); $p->set_attribute( 'data-wp-context', '{}' ); diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index 6623a9a8481bc7..5688e2871a2463 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -47,7 +47,7 @@ function render_block_core_search( $attributes ) { $border_color_classes = get_border_color_classes_for_block_core_search( $attributes ); // This variable is a constant and its value is always false at this moment. // It is defined this way because some values depend on it, in case it changes in the future. - $open_by_default = 'false'; + $open_by_default = false; $label_inner_html = empty( $attributes['label'] ) ? __( 'Search' ) : wp_kses_post( $attributes['label'] ); $label = new WP_HTML_Tag_Processor( sprintf( '', $inline_styles['label'], $label_inner_html ) ); @@ -179,12 +179,20 @@ function render_block_core_search( $attributes ) { if ( $is_expandable_searchfield ) { $aria_label_expanded = __( 'Submit Search' ); $aria_label_collapsed = __( 'Expand search field' ); + $form_context = data_wp_context( + array( + 'isSearchInputVisible' => $open_by_default, + 'inputId' => $input_id, + 'ariaLabelExpanded' => $aria_label_expanded, + 'ariaLabelCollapsed' => $aria_label_collapsed, + ) + ); $form_directives = ' - data-wp-interactive=\'{ "namespace": "core/search" }\' - data-wp-context=\'{ "isSearchInputVisible": ' . $open_by_default . ', "inputId": "' . $input_id . '", "ariaLabelExpanded": "' . $aria_label_expanded . '", "ariaLabelCollapsed": "' . $aria_label_collapsed . '" }\' - data-wp-class--wp-block-search__searchfield-hidden="!context.isSearchInputVisible" - data-wp-on--keydown="actions.handleSearchKeydown" - data-wp-on--focusout="actions.handleSearchFocusout" + data-wp-interactive=\'"core/search"\'' + . $form_context . + 'data-wp-class--wp-block-search__searchfield-hidden="!context.isSearchInputVisible" + data-wp-on--keydown="actions.handleSearchKeydown" + data-wp-on--focusout="actions.handleSearchFocusout" '; } diff --git a/phpunit/blocks/render-query-test.php b/phpunit/blocks/render-query-test.php index a121c490d747c5..a68bd2c7adcbac 100644 --- a/phpunit/blocks/render-query-test.php +++ b/phpunit/blocks/render-query-test.php @@ -86,7 +86,7 @@ public function test_rendering_query_with_enhanced_pagination() { $p->next_tag( array( 'class_name' => 'wp-block-query' ) ); $this->assertSame( '{}', $p->get_attribute( 'data-wp-context' ) ); $this->assertSame( 'query-0', $p->get_attribute( 'data-wp-router-region' ) ); - $this->assertSame( '{"namespace":"core/query"}', $p->get_attribute( 'data-wp-interactive' ) ); + $this->assertSame( 'core/query', $p->get_attribute( 'data-wp-interactive' ) ); $p->next_tag( array( 'class_name' => 'wp-block-post' ) ); $this->assertSame( 'post-template-item-' . self::$posts[1], $p->get_attribute( 'data-wp-key' ) ); From 46eb65dc178162cc882019ed6865f756a737c2d3 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Mon, 12 Feb 2024 13:50:21 +0100 Subject: [PATCH 14/16] Upgrade Floating UI packages, fix nested iframe positioning bug (#58932) * Upgrade Floating UI packages, fix nested iframe positioning bug * Update components changelog --- package-lock.json | 114 +++++++++++++------------------ packages/components/CHANGELOG.md | 4 ++ packages/components/package.json | 2 +- 3 files changed, 51 insertions(+), 69 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7e5ce8c965e81f..f3885e822e3bd8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5131,26 +5131,38 @@ "dev": true }, "node_modules/@floating-ui/core": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.4.1.tgz", - "integrity": "sha512-jk3WqquEJRlcyu7997NtR5PibI+y5bi+LS3hPmguVClypenMsCY3CBa3LAQnozRCtCrYWSEtAdiskpamuJRFOQ==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.0.tgz", + "integrity": "sha512-PcF++MykgmTj3CIyOQbKA/hDzOAiqI3mhuoN44WRCopIs1sgoDoU4oty4Jtqaj/y3oDU6fnVSm4QG0a3t5i0+g==", "dependencies": { - "@floating-ui/utils": "^0.1.1" + "@floating-ui/utils": "^0.2.1" } }, "node_modules/@floating-ui/dom": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.5.1.tgz", - "integrity": "sha512-KwvVcPSXg6mQygvA1TjbN/gh///36kKtllIF8SUm0qpFj8+rvYrpvlYdL1JoA71SHpDqgSSdGOSoQ0Mp3uY5aw==", + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.3.tgz", + "integrity": "sha512-RnDthu3mzPlQ31Ss/BTwQ1zjzIhr3lk1gZB1OC56h/1vEtaXkESrOqL5fQVMfXpwGtRwX+YsZBdyHtJMQnkArw==", "dependencies": { - "@floating-ui/core": "^1.4.1", - "@floating-ui/utils": "^0.1.1" + "@floating-ui/core": "^1.0.0", + "@floating-ui/utils": "^0.2.0" + } + }, + "node_modules/@floating-ui/react-dom": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.8.tgz", + "integrity": "sha512-HOdqOt3R3OGeTKidaLvJKcgg75S6tibQ3Tif4eyd91QnIJWr0NLvoXFpJA/j8HqkFSL68GDca9AuyWEHlhyClw==", + "dependencies": { + "@floating-ui/dom": "^1.6.1" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" } }, "node_modules/@floating-ui/utils": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.1.2.tgz", - "integrity": "sha512-ou3elfqG/hZsbmF4bxeJhPHIf3G2pm0ujc39hYEZrfVqt7Vk/Zji6CXc3W0pmYM8BW1g40U+akTl9DKZhFhInQ==" + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.1.tgz", + "integrity": "sha512-9TANp6GPoMtYzQdt54kfAyMmz1+osLlXdg2ENroU7zzrtflTLrrC/lgrIfaSe+Wu0b89GKccT7vxXA0MoAIO+Q==" }, "node_modules/@geometricpanda/storybook-addon-badges": { "version": "2.0.1", @@ -7724,19 +7736,6 @@ } } }, - "node_modules/@radix-ui/react-select/node_modules/@floating-ui/react-dom": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.1.tgz", - "integrity": "sha512-rZtAmSht4Lry6gdhAJDrCp/6rKN7++JnL1/Anbr/DdeyYXQPxvg/ivrbYvJulbRf4vL8b212suwMM2lxbv+RQA==", - "dev": true, - "dependencies": { - "@floating-ui/dom": "^1.3.0" - }, - "peerDependencies": { - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, "node_modules/@radix-ui/react-select/node_modules/@radix-ui/primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.0.1.tgz", @@ -53994,7 +53993,7 @@ "@emotion/serialize": "^1.0.2", "@emotion/styled": "^11.6.0", "@emotion/utils": "^1.0.0", - "@floating-ui/react-dom": "^2.0.1", + "@floating-ui/react-dom": "^2.0.8", "@types/gradient-parser": "0.1.3", "@types/highlight-words-core": "1.2.1", "@use-gesture/react": "^10.2.24", @@ -54044,18 +54043,6 @@ "react-dom": "^18.0.0" } }, - "packages/components/node_modules/@floating-ui/react-dom": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.1.tgz", - "integrity": "sha512-rZtAmSht4Lry6gdhAJDrCp/6rKN7++JnL1/Anbr/DdeyYXQPxvg/ivrbYvJulbRf4vL8b212suwMM2lxbv+RQA==", - "dependencies": { - "@floating-ui/dom": "^1.3.0" - }, - "peerDependencies": { - "react": ">=16.8.0", - "react-dom": ">=16.8.0" - } - }, "packages/components/node_modules/@types/gradient-parser": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@types/gradient-parser/-/gradient-parser-0.1.3.tgz", @@ -59590,26 +59577,34 @@ "dev": true }, "@floating-ui/core": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.4.1.tgz", - "integrity": "sha512-jk3WqquEJRlcyu7997NtR5PibI+y5bi+LS3hPmguVClypenMsCY3CBa3LAQnozRCtCrYWSEtAdiskpamuJRFOQ==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.0.tgz", + "integrity": "sha512-PcF++MykgmTj3CIyOQbKA/hDzOAiqI3mhuoN44WRCopIs1sgoDoU4oty4Jtqaj/y3oDU6fnVSm4QG0a3t5i0+g==", "requires": { - "@floating-ui/utils": "^0.1.1" + "@floating-ui/utils": "^0.2.1" } }, "@floating-ui/dom": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.5.1.tgz", - "integrity": "sha512-KwvVcPSXg6mQygvA1TjbN/gh///36kKtllIF8SUm0qpFj8+rvYrpvlYdL1JoA71SHpDqgSSdGOSoQ0Mp3uY5aw==", + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/@floating-ui/dom/-/dom-1.6.3.tgz", + "integrity": "sha512-RnDthu3mzPlQ31Ss/BTwQ1zjzIhr3lk1gZB1OC56h/1vEtaXkESrOqL5fQVMfXpwGtRwX+YsZBdyHtJMQnkArw==", "requires": { - "@floating-ui/core": "^1.4.1", - "@floating-ui/utils": "^0.1.1" + "@floating-ui/core": "^1.0.0", + "@floating-ui/utils": "^0.2.0" + } + }, + "@floating-ui/react-dom": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.8.tgz", + "integrity": "sha512-HOdqOt3R3OGeTKidaLvJKcgg75S6tibQ3Tif4eyd91QnIJWr0NLvoXFpJA/j8HqkFSL68GDca9AuyWEHlhyClw==", + "requires": { + "@floating-ui/dom": "^1.6.1" } }, "@floating-ui/utils": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.1.2.tgz", - "integrity": "sha512-ou3elfqG/hZsbmF4bxeJhPHIf3G2pm0ujc39hYEZrfVqt7Vk/Zji6CXc3W0pmYM8BW1g40U+akTl9DKZhFhInQ==" + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.2.1.tgz", + "integrity": "sha512-9TANp6GPoMtYzQdt54kfAyMmz1+osLlXdg2ENroU7zzrtflTLrrC/lgrIfaSe+Wu0b89GKccT7vxXA0MoAIO+Q==" }, "@geometricpanda/storybook-addon-badges": { "version": "2.0.1", @@ -61538,15 +61533,6 @@ "react-remove-scroll": "2.5.5" }, "dependencies": { - "@floating-ui/react-dom": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.1.tgz", - "integrity": "sha512-rZtAmSht4Lry6gdhAJDrCp/6rKN7++JnL1/Anbr/DdeyYXQPxvg/ivrbYvJulbRf4vL8b212suwMM2lxbv+RQA==", - "dev": true, - "requires": { - "@floating-ui/dom": "^1.3.0" - } - }, "@radix-ui/primitive": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@radix-ui/primitive/-/primitive-1.0.1.tgz", @@ -69135,7 +69121,7 @@ "@emotion/serialize": "^1.0.2", "@emotion/styled": "^11.6.0", "@emotion/utils": "^1.0.0", - "@floating-ui/react-dom": "^2.0.1", + "@floating-ui/react-dom": "^2.0.8", "@types/gradient-parser": "0.1.3", "@types/highlight-words-core": "1.2.1", "@use-gesture/react": "^10.2.24", @@ -69178,14 +69164,6 @@ "valtio": "1.7.0" }, "dependencies": { - "@floating-ui/react-dom": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@floating-ui/react-dom/-/react-dom-2.0.1.tgz", - "integrity": "sha512-rZtAmSht4Lry6gdhAJDrCp/6rKN7++JnL1/Anbr/DdeyYXQPxvg/ivrbYvJulbRf4vL8b212suwMM2lxbv+RQA==", - "requires": { - "@floating-ui/dom": "^1.3.0" - } - }, "@types/gradient-parser": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@types/gradient-parser/-/gradient-parser-0.1.3.tgz", diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index b06aeab54a67e1..67a101bdc64007 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Bug Fix + +- `Popover`: Fix positioning in nested iframes by upgrading Floating UI packages to their latest versions ([#58932](https://github.com/WordPress/gutenberg/pull/58932)). + ## 26.0.0 (2024-02-09) ### Breaking Changes diff --git a/packages/components/package.json b/packages/components/package.json index 74247e87dc96cc..3b3e9e609ce58c 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -38,7 +38,7 @@ "@emotion/serialize": "^1.0.2", "@emotion/styled": "^11.6.0", "@emotion/utils": "^1.0.0", - "@floating-ui/react-dom": "^2.0.1", + "@floating-ui/react-dom": "^2.0.8", "@types/gradient-parser": "0.1.3", "@types/highlight-words-core": "1.2.1", "@use-gesture/react": "^10.2.24", From 8c4449764fb68aa286c581f883d15d52ec78b694 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Tue, 13 Feb 2024 11:56:44 +0100 Subject: [PATCH 15/16] Fix layout for non viewable post types (#58962) Co-authored-by: youknowriad Co-authored-by: glendaviesnz Co-authored-by: t-hamano --- .../src/components/editor-canvas/index.js | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/editor/src/components/editor-canvas/index.js b/packages/editor/src/components/editor-canvas/index.js index f011f285644c0e..bc7d54583afbda 100644 --- a/packages/editor/src/components/editor-canvas/index.js +++ b/packages/editor/src/components/editor-canvas/index.js @@ -40,6 +40,17 @@ const { const noop = () => {}; +/** + * These post types have a special editor where they don't allow you to fill the title + * and they don't apply the layout styles. + */ +const DESIGN_POST_TYPES = [ + 'wp_block', + 'wp_template', + 'wp_navigation', + 'wp_template_part', +]; + /** * Given an array of nested blocks, find the first Post Content * block inside it, recursing through any nesting levels, @@ -93,6 +104,7 @@ function EditorCanvas( { wrapperUniqueId, deviceType, showEditorPadding, + isDesignPostType, } = useSelect( ( select ) => { const { getCurrentPostId, @@ -130,6 +142,7 @@ function EditorCanvas( { return { renderingMode: _renderingMode, postContentAttributes: editorSettings.postContentAttributes, + isDesignPostType: DESIGN_POST_TYPES.includes( postTypeSlug ), // Post template fetch returns a 404 on classic themes, which // messes with e2e tests, so check it's a block theme first. editedPostTemplate: @@ -164,7 +177,7 @@ function EditorCanvas( { // fallbackLayout is used if there is no Post Content, // and for Post Title. const fallbackLayout = useMemo( () => { - if ( renderingMode !== 'post-only' ) { + if ( renderingMode !== 'post-only' || isDesignPostType ) { return { type: 'default' }; } @@ -175,7 +188,12 @@ function EditorCanvas( { } // Set default layout for classic themes so all alignments are supported. return { type: 'default' }; - }, [ renderingMode, themeSupportsLayout, globalLayoutSettings ] ); + }, [ + renderingMode, + themeSupportsLayout, + globalLayoutSettings, + isDesignPostType, + ] ); const newestPostContentAttributes = useMemo( () => { if ( @@ -318,7 +336,8 @@ function EditorCanvas( { > { themeSupportsLayout && ! themeHasDisabledLayoutStyles && - renderingMode === 'post-only' && ( + renderingMode === 'post-only' && + ! isDesignPostType && ( <> ) } - { renderingMode === 'post-only' && ( + { renderingMode === 'post-only' && ! isDesignPostType && (
    Date: Tue, 13 Feb 2024 13:06:18 +0200 Subject: [PATCH 16/16] DataViews: Remove second `reset filter` button in filter dialog (#58960) Co-authored-by: ntsekouras Co-authored-by: jameskoster --- packages/dataviews/src/filter-summary.js | 39 ------------------------ packages/dataviews/src/style.scss | 5 --- 2 files changed, 44 deletions(-) diff --git a/packages/dataviews/src/filter-summary.js b/packages/dataviews/src/filter-summary.js index bbe0000c05dcbd..6e1e3e9e2620b1 100644 --- a/packages/dataviews/src/filter-summary.js +++ b/packages/dataviews/src/filter-summary.js @@ -8,7 +8,6 @@ import classnames from 'classnames'; */ import { Dropdown, - Button, __experimentalVStack as VStack, __experimentalHStack as HStack, FlexItem, @@ -133,40 +132,6 @@ function OperatorSelector( { filter, view, onChangeView } ) { ); } -function ResetFilter( { filter, view, onChangeView, addFilterRef } ) { - const isDisabled = - filter.isPrimary && - view.filters.find( ( _filter ) => _filter.field === filter.field ) - ?.value === undefined; - return ( -
    - -
    - ); -} - export default function FilterSummary( { addFilterRef, openedFilter, @@ -269,10 +234,6 @@ export default function FilterSummary( { - ); } } diff --git a/packages/dataviews/src/style.scss b/packages/dataviews/src/style.scss index afb5df37cc2dd2..7b143958e2c16e 100644 --- a/packages/dataviews/src/style.scss +++ b/packages/dataviews/src/style.scss @@ -627,11 +627,6 @@ } } -.dataviews-filter-summary__reset { - padding: $grid-unit-05; - border-top: 1px solid $gray-200; -} - .dataviews-filter-summary__chip-container { position: relative; white-space: pre-wrap;