From 0dc55a842ae9d124601ae6577c4ff5f24898f428 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Tue, 20 Feb 2024 13:57:37 +1100 Subject: [PATCH 01/24] DocumentBar: Simplify component, use framer for animation (#58656) * DocumentBar: Simplify component, use framer for animation * Disable animation if reduced motion is on Co-authored-by: noisysocks Co-authored-by: ramonjd Co-authored-by: youknowriad --- .../src/components/document-bar/index.js | 203 ++++++++++-------- .../src/components/document-bar/style.scss | 37 ---- 2 files changed, 114 insertions(+), 126 deletions(-) diff --git a/packages/editor/src/components/document-bar/index.js b/packages/editor/src/components/document-bar/index.js index 2ac03a63e73fb..84005331d18bb 100644 --- a/packages/editor/src/components/document-bar/index.js +++ b/packages/editor/src/components/document-bar/index.js @@ -12,6 +12,8 @@ import { Button, __experimentalText as Text, __experimentalHStack as HStack, + __unstableMotion as motion, + __unstableAnimatePresence as AnimatePresence, } from '@wordpress/components'; import { BlockIcon } from '@wordpress/block-editor'; import { @@ -22,16 +24,17 @@ import { symbol, } from '@wordpress/icons'; import { displayShortcut } from '@wordpress/keycodes'; -import { useEntityRecord } from '@wordpress/core-data'; +import { store as coreStore } from '@wordpress/core-data'; import { store as commandsStore } from '@wordpress/commands'; -import { useState, useEffect, useRef } from '@wordpress/element'; +import { useRef, useEffect } from '@wordpress/element'; +import { useReducedMotion } from '@wordpress/compose'; /** * Internal dependencies */ import { store as editorStore } from '../../store'; -const typeLabels = { +const TYPE_LABELS = { // translators: 1: Pattern title. wp_pattern: __( 'Editing pattern: %s' ), // translators: 1: Navigation menu title. @@ -42,127 +45,149 @@ const typeLabels = { wp_template_part: __( 'Editing template part: %s' ), }; -const icons = { +const ICONS = { wp_block: symbol, wp_navigation: navigationIcon, }; -export default function DocumentBar() { - const { postType, postId, onNavigateToPreviousEntityRecord } = useSelect( - ( select ) => { - const { - getCurrentPostId, - getCurrentPostType, - getEditorSettings: getSettings, - } = select( editorStore ); - return { - postType: getCurrentPostType(), - postId: getCurrentPostId(), - onNavigateToPreviousEntityRecord: - getSettings().onNavigateToPreviousEntityRecord, - getEditorSettings: getSettings, - }; - }, - [] - ); +const TEMPLATE_POST_TYPES = [ 'wp_template', 'wp_template_part' ]; - const handleOnBack = () => { - if ( onNavigateToPreviousEntityRecord ) { - onNavigateToPreviousEntityRecord(); - } - }; +const GLOBAL_POST_TYPES = [ + ...TEMPLATE_POST_TYPES, + 'wp_block', + 'wp_navigation', +]; - return ( - - ); -} +const MotionButton = motion( Button ); -function BaseDocumentActions( { postType, postId, onBack } ) { - const { open: openCommandCenter } = useDispatch( commandsStore ); - const { editedRecord: doc, isResolving } = useEntityRecord( - 'postType', +export default function DocumentBar() { + const { postType, - postId - ); - const { templateIcon, templateTitle } = useSelect( ( select ) => { - const { __experimentalGetTemplateInfo: getTemplateInfo } = - select( editorStore ); - const templateInfo = getTemplateInfo( doc ); + document, + isResolving, + templateIcon, + templateTitle, + onNavigateToPreviousEntityRecord, + } = useSelect( ( select ) => { + const { + getCurrentPostType, + getCurrentPostId, + getEditorSettings, + __experimentalGetTemplateInfo: getTemplateInfo, + } = select( editorStore ); + const { getEditedEntityRecord, getIsResolving } = select( coreStore ); + const _postType = getCurrentPostType(); + const _postId = getCurrentPostId(); + const _document = getEditedEntityRecord( + 'postType', + _postType, + _postId + ); + const _templateInfo = getTemplateInfo( _document ); return { - templateIcon: templateInfo.icon, - templateTitle: templateInfo.title, + postType: _postType, + document: _document, + isResolving: getIsResolving( + 'getEditedEntityRecord', + 'postType', + _postType, + _postId + ), + templateIcon: _templateInfo.icon, + templateTitle: _templateInfo.title, + onNavigateToPreviousEntityRecord: + getEditorSettings().onNavigateToPreviousEntityRecord, }; - } ); - const isNotFound = ! doc && ! isResolving; - const icon = icons[ postType ] ?? pageIcon; - const [ isAnimated, setIsAnimated ] = useState( false ); - const isMounting = useRef( true ); - const isTemplate = [ 'wp_template', 'wp_template_part' ].includes( - postType - ); - const isGlobalEntity = [ - 'wp_template', - 'wp_navigation', - 'wp_template_part', - 'wp_block', - ].includes( postType ); + }, [] ); - useEffect( () => { - if ( ! isMounting.current ) { - setIsAnimated( true ); - } - isMounting.current = false; - }, [ postType, postId ] ); + const { open: openCommandCenter } = useDispatch( commandsStore ); + const isReducedMotion = useReducedMotion(); + + const isNotFound = ! document && ! isResolving; + const icon = ICONS[ postType ] ?? pageIcon; + const isTemplate = TEMPLATE_POST_TYPES.includes( postType ); + const isGlobalEntity = GLOBAL_POST_TYPES.includes( postType ); + const hasBackButton = !! onNavigateToPreviousEntityRecord; + const title = isTemplate ? templateTitle : document.title; - const title = isTemplate ? templateTitle : doc.title; + const mounted = useRef( false ); + useEffect( () => { + mounted.current = true; + }, [] ); return (
- { onBack && ( - - ) } - { isNotFound && { __( 'Document not found' ) } } - { ! isNotFound && ( + + { hasBackButton && ( + { + event.stopPropagation(); + onNavigateToPreviousEntityRecord(); + } } + size="compact" + initial={ + mounted.current + ? { opacity: 0, transform: 'translateX(15%)' } + : false // Don't show entry animation when DocumentBar mounts. + } + animate={ { opacity: 1, transform: 'translateX(0%)' } } + exit={ { opacity: 0, transform: 'translateX(15%)' } } + transition={ + isReducedMotion ? { duration: 0 } : undefined + } + > + { __( 'Back' ) } + + ) } + + { isNotFound ? ( + { __( 'Document not found' ) } + ) : ( ) : null; -}; - -/** - * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/skip-to-selected-block/README.md - */ -export default withSelect( ( select ) => { - return { - selectedBlockClientId: - select( blockEditorStore ).getBlockSelectionStart(), - }; -} )( SkipToSelectedBlock ); +} From e1cd1302696054b37c32a2878ad8577b4250145b Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> Date: Tue, 20 Feb 2024 09:33:41 -0500 Subject: [PATCH 09/24] Remove reference to CODE_OF_CONDUCT.md in docs. (#59206) Co-authored-by: desrosj Co-authored-by: Mamaduka --- docs/contributors/folder-structure.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/contributors/folder-structure.md b/docs/contributors/folder-structure.md index 9cee302794cda..98eccf1b2029b 100644 --- a/docs/contributors/folder-structure.md +++ b/docs/contributors/folder-structure.md @@ -7,7 +7,6 @@ The following snippet explains how the Gutenberg repository is structured omitti ├── README.md ├── SECURITY.md ├── CONTRIBUTING.md - ├── CODE_OF_CONDUCT.md │ ├── .editorconfig ├── .eslintignore From a4161ced3ec0e50d6a31875ae287fc5316b6821b Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Tue, 20 Feb 2024 17:19:09 +0200 Subject: [PATCH 10/24] DataViews: Fix pages list back path (#59201) Co-authored-by: ntsekouras Co-authored-by: youknowriad --- packages/edit-site/src/components/sidebar/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/edit-site/src/components/sidebar/index.js b/packages/edit-site/src/components/sidebar/index.js index ea705b25efde3..7cf049282618b 100644 --- a/packages/edit-site/src/components/sidebar/index.js +++ b/packages/edit-site/src/components/sidebar/index.js @@ -76,6 +76,7 @@ function SidebarScreens() { } + backPath="/page" /> From 9ce80a0e01d3a484b271e1c6a3c55bc4542c79cf Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Wed, 21 Feb 2024 00:43:00 +0900 Subject: [PATCH 11/24] Patterns Page: Make category action button compact (#59203) Co-authored-by: t-hamano Co-authored-by: jameskoster --- packages/edit-site/src/components/page-patterns/header.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/edit-site/src/components/page-patterns/header.js b/packages/edit-site/src/components/page-patterns/header.js index a5b19e4e3a6b9..ce078900a5229 100644 --- a/packages/edit-site/src/components/page-patterns/header.js +++ b/packages/edit-site/src/components/page-patterns/header.js @@ -69,6 +69,7 @@ export default function PatternsHeader( { __( 'Action menu for %s pattern category' ), title ), + size: 'compact', } } > { ( { onClose } ) => ( From a016d8240121a1ed4c44ac17dc0e3dbc22c15eae Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Tue, 20 Feb 2024 15:47:54 +0000 Subject: [PATCH 12/24] Template inspector: Surface related patterns (#55091) [7bc5ee8707] template-panel/index rebase [4d47f77146] Make titles tooltips (+8 squashed commits) Squashed commits: [3488f2f164] Layout tweaks [f450cd5a91] remove CSS [b3990a7119] remove unused file [3bd79a7515] update comment [e07cd80b74] Add comments [aaae875b5a] Let users select a pattern [4aa4272d2e] fetch patterns not template parts [3f3da4b3df] Add template parts to template parts (whoops) * Make things panel open by default for template parts --------- Co-authored-by: scruffian Co-authored-by: jorgefilipecosta Co-authored-by: carolinan Co-authored-by: glendaviesnz Co-authored-by: MaggieCabrera Co-authored-by: draganescu Co-authored-by: annezazu Co-authored-by: richtabor Co-authored-by: jasmussen Co-authored-by: oandregal Co-authored-by: paaljoachim Co-authored-by: mtias Co-authored-by: SaxonF Co-authored-by: jameskoster --- .../sidebar-edit-mode/template-panel/hooks.js | 59 +++++++----- .../sidebar-edit-mode/template-panel/index.js | 91 +++++++++++++++---- .../template-panel/replace-template-button.js | 89 ------------------ .../template-panel/style.scss | 19 +--- .../template-panel/template-actions.js | 13 +-- 5 files changed, 114 insertions(+), 157 deletions(-) delete mode 100644 packages/edit-site/src/components/sidebar-edit-mode/template-panel/replace-template-button.js diff --git a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/hooks.js b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/hooks.js index 87f99e8991e45..73304a4d9b699 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/hooks.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/hooks.js @@ -36,7 +36,14 @@ function injectThemeAttributeInBlockTemplateContent( return block; } -function preparePatterns( patterns, template, currentThemeStylesheet ) { +/** + * Filter all patterns and return only the ones that are compatible with the current template. + * + * @param {Array} patterns An array of patterns. + * @param {Object} template The current template. + * @return {Array} Array of patterns that are compatible with the current template. + */ +function filterPatterns( patterns, template ) { // Filter out duplicates. const filterOutDuplicatesByName = ( currentItem, index, items ) => index === items.findIndex( ( item ) => currentItem.name === item.name ); @@ -45,30 +52,33 @@ function preparePatterns( patterns, template, currentThemeStylesheet ) { const filterOutExcludedPatternSources = ( pattern ) => ! EXCLUDED_PATTERN_SOURCES.includes( pattern.source ); - // Filter only the patterns that are compatible with the current template. + // Looks for patterns that have the same template type as the current template, + // or have a block type that matches the current template area. const filterCompatiblePatterns = ( pattern ) => - pattern.templateTypes?.includes( template.slug ); + pattern.templateTypes?.includes( template.slug ) || + pattern.blockTypes?.includes( 'core/template-part/' + template.area ); - return patterns - .filter( - ( pattern, index, items ) => - filterOutExcludedPatternSources( pattern ) && - filterOutDuplicatesByName( pattern, index, items ) && - filterCompatiblePatterns( pattern ) - ) - .map( ( pattern ) => ( { - ...pattern, - keywords: pattern.keywords || [], - type: PATTERN_TYPES.theme, - blocks: parse( pattern.content, { - __unstableSkipMigrationLogs: true, - } ).map( ( block ) => - injectThemeAttributeInBlockTemplateContent( - block, - currentThemeStylesheet - ) - ), - } ) ); + return patterns.filter( + filterOutDuplicatesByName && + filterOutExcludedPatternSources && + filterCompatiblePatterns + ); +} + +function preparePatterns( patterns, template, currentThemeStylesheet ) { + return patterns.map( ( pattern ) => ( { + ...pattern, + keywords: pattern.keywords || [], + type: PATTERN_TYPES.theme, + blocks: parse( pattern.content, { + __unstableSkipMigrationLogs: true, + } ).map( ( block ) => + injectThemeAttributeInBlockTemplateContent( + block, + currentThemeStylesheet + ) + ), + } ) ); } export function useAvailablePatterns( template ) { @@ -92,8 +102,9 @@ export function useAvailablePatterns( template ) { ...( blockPatterns || [] ), ...( restBlockPatterns || [] ), ]; + const filteredPatterns = filterPatterns( mergedPatterns, template ); return preparePatterns( - mergedPatterns, + filteredPatterns, template, currentThemeStylesheet ); diff --git a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js index 21df325ee34c2..9d57995d16330 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js @@ -1,8 +1,8 @@ /** * WordPress dependencies */ -import { useSelect } from '@wordpress/data'; -import { PanelBody } from '@wordpress/components'; +import { useSelect, useDispatch } from '@wordpress/data'; +import { PanelBody, PanelRow } from '@wordpress/components'; import { PageAttributesPanel, PostDiscussionPanel, @@ -15,6 +15,10 @@ import { import { store as coreStore } from '@wordpress/core-data'; import { decodeEntities } from '@wordpress/html-entities'; import { navigation, symbol } from '@wordpress/icons'; +import { __ } from '@wordpress/i18n'; +import { useAsyncList } from '@wordpress/compose'; +import { serialize } from '@wordpress/blocks'; +import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor'; /** * Internal dependencies @@ -23,36 +27,71 @@ import { store as editSiteStore } from '../../../store'; import TemplateActions from './template-actions'; import TemplateAreas from './template-areas'; import SidebarCard from '../sidebar-card'; +import { useAvailablePatterns } from './hooks'; +import { TEMPLATE_PART_POST_TYPE } from '../../../utils/constants'; const CARD_ICONS = { wp_block: symbol, wp_navigation: navigation, }; +function TemplatesList( { availableTemplates, onSelect } ) { + const shownTemplates = useAsyncList( availableTemplates ); + if ( ! availableTemplates || availableTemplates?.length < 2 ) { + return null; + } + + return ( + + ); +} + export default function TemplatePanel() { - const { title, description, icon, record } = useSelect( ( select ) => { - const { getEditedPostType, getEditedPostId } = select( editSiteStore ); - const { getEditedEntityRecord } = select( coreStore ); - const { __experimentalGetTemplateInfo: getTemplateInfo } = - select( editorStore ); + const { title, description, icon, record, postType, postId } = useSelect( + ( select ) => { + const { getEditedPostType, getEditedPostId } = + select( editSiteStore ); + const { getEditedEntityRecord } = select( coreStore ); + const { __experimentalGetTemplateInfo: getTemplateInfo } = + select( editorStore ); + + const type = getEditedPostType(); + const _postId = getEditedPostId(); + const _record = getEditedEntityRecord( 'postType', type, _postId ); + const info = getTemplateInfo( _record ); - const type = getEditedPostType(); - const postId = getEditedPostId(); - const _record = getEditedEntityRecord( 'postType', type, postId ); - const info = getTemplateInfo( _record ); + return { + title: info.title, + description: info.description, + icon: info.icon, + record: _record, + postType: type, + postId: _postId, + }; + }, + [] + ); - return { - title: info.title, - description: info.description, - icon: info.icon, - record: _record, - }; - }, [] ); + const availablePatterns = useAvailablePatterns( record ); + const { editEntityRecord } = useDispatch( coreStore ); if ( ! title && ! description ) { return null; } + const onTemplateSelect = async ( selectedTemplate ) => { + await editEntityRecord( 'postType', postType, postId, { + blocks: selectedTemplate.blocks, + content: serialize( selectedTemplate.blocks ), + } ); + }; + return ( <> @@ -66,6 +105,22 @@ export default function TemplatePanel() { + + +

+ { __( + 'Choose a predefined pattern to switch up the look of your template.' // TODO - make this dynamic? + ) } +

+
+ +
diff --git a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/replace-template-button.js b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/replace-template-button.js deleted file mode 100644 index 658aacd331deb..0000000000000 --- a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/replace-template-button.js +++ /dev/null @@ -1,89 +0,0 @@ -/** - * WordPress dependencies - */ -import { useSelect, useDispatch } from '@wordpress/data'; -import { useState } from '@wordpress/element'; -import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor'; -import { MenuItem, Modal } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; -import { store as coreStore } from '@wordpress/core-data'; -import { useAsyncList } from '@wordpress/compose'; -import { serialize } from '@wordpress/blocks'; - -/** - * Internal dependencies - */ -import { store as editSiteStore } from '../../../store'; - -export default function ReplaceTemplateButton( { - onClick, - availableTemplates, -} ) { - const { editEntityRecord } = useDispatch( coreStore ); - const [ showModal, setShowModal ] = useState( false ); - const onClose = () => { - setShowModal( false ); - }; - - const { postId, postType } = useSelect( ( select ) => { - return { - postId: select( editSiteStore ).getEditedPostId(), - postType: select( editSiteStore ).getEditedPostType(), - }; - }, [] ); - - const onTemplateSelect = async ( selectedTemplate ) => { - onClose(); // Close the template suggestions modal first. - onClick(); - await editEntityRecord( 'postType', postType, postId, { - blocks: selectedTemplate.blocks, - content: serialize( selectedTemplate.blocks ), - } ); - }; - - if ( ! availableTemplates.length || availableTemplates.length < 1 ) { - return null; - } - - return ( - <> - setShowModal( true ) } - > - { __( 'Replace template' ) } - - - { showModal && ( - -
- -
-
- ) } - - ); -} - -function TemplatesList( { availableTemplates, onSelect } ) { - const shownTemplates = useAsyncList( availableTemplates ); - - return ( - - ); -} diff --git a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/style.scss b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/style.scss index f2865195aa5b8..ab1bc3baed5aa 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/style.scss +++ b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/style.scss @@ -34,20 +34,11 @@ h3.edit-site-template-card__template-areas-title { margin: 0 0 $grid-unit-10; } - -.edit-site-template-panel__replace-template-modal { - z-index: z-index(".edit-site-template-panel__replace-template-modal"); +.edit-site-template-card__templates-list { + margin-top: $grid-unit-20; } -.edit-site-template-panel__replace-template-modal__content { - column-count: 2; - column-gap: $grid-unit-30; - - @include break-medium() { - column-count: 3; - } - - @include break-wide() { - column-count: 4; - } +.edit-site-template-panel .block-editor-block-preview__container { + border-radius: 2px; + box-shadow: none; } diff --git a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/template-actions.js b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/template-actions.js index 81acb244a1186..e4b8d49499949 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/template-actions.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/template-actions.js @@ -11,18 +11,12 @@ import { moreVertical } from '@wordpress/icons'; */ import { store as editSiteStore } from '../../../store'; import isTemplateRevertable from '../../../utils/is-template-revertable'; -import ReplaceTemplateButton from './replace-template-button'; -import { useAvailablePatterns } from './hooks'; export default function Actions( { template } ) { - const availablePatterns = useAvailablePatterns( template ); const { revertTemplate } = useDispatch( editSiteStore ); const isRevertable = isTemplateRevertable( template ); - if ( - ! isRevertable && - ( ! availablePatterns.length || availablePatterns.length < 1 ) - ) { + if ( ! isRevertable ) { return null; } @@ -48,11 +42,6 @@ export default function Actions( { template } ) { { __( 'Clear customizations' ) } ) } - ) } From 5e7152f449a9559c64966d758ddb537491fb3eb7 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Tue, 20 Feb 2024 16:27:17 +0000 Subject: [PATCH 13/24] Fix: Logical error in filterPatterns on sidebar-edit-mode/template-panel/hooks.js. (#59218) Co-authored-by: scruffian Co-authored-by: jorgefilipecosta Co-authored-by: MaggieCabrera Co-authored-by: ntsekouras Co-authored-by: anton-vlasenko --- .../sidebar-edit-mode/template-panel/hooks.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/hooks.js b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/hooks.js index 73304a4d9b699..128a74da39070 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/hooks.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/hooks.js @@ -58,11 +58,13 @@ function filterPatterns( patterns, template ) { pattern.templateTypes?.includes( template.slug ) || pattern.blockTypes?.includes( 'core/template-part/' + template.area ); - return patterns.filter( - filterOutDuplicatesByName && - filterOutExcludedPatternSources && - filterCompatiblePatterns - ); + return patterns.filter( ( pattern, index, items ) => { + return ( + filterOutDuplicatesByName( pattern, index, items ) && + filterOutExcludedPatternSources( pattern ) && + filterCompatiblePatterns( pattern ) + ); + } ); } function preparePatterns( patterns, template, currentThemeStylesheet ) { From eac792079716c19be255971f1b009f6cdaf44ca1 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Tue, 20 Feb 2024 16:28:57 +0000 Subject: [PATCH 14/24] Fix: Don't render the Transform Into template panel if there are no patterns to show. (#59217) Co-authored-by: scruffian Co-authored-by: jorgefilipecosta Co-authored-by: MaggieCabrera Co-authored-by: ntsekouras Co-authored-by: anton-vlasenko --- .../sidebar-edit-mode/template-panel/index.js | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js index 9d57995d16330..0b7bc4ee0a961 100644 --- a/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js +++ b/packages/edit-site/src/components/sidebar-edit-mode/template-panel/index.js @@ -37,7 +37,7 @@ const CARD_ICONS = { function TemplatesList( { availableTemplates, onSelect } ) { const shownTemplates = useAsyncList( availableTemplates ); - if ( ! availableTemplates || availableTemplates?.length < 2 ) { + if ( ! availableTemplates || availableTemplates?.length === 0 ) { return null; } @@ -105,22 +105,25 @@ export default function TemplatePanel() { - - -

- { __( - 'Choose a predefined pattern to switch up the look of your template.' // TODO - make this dynamic? - ) } -

-
- -
+ { availablePatterns?.length > 0 && ( + + +

+ { __( + 'Choose a predefined pattern to switch up the look of your template.' // TODO - make this dynamic? + ) } +

+
+ + +
+ ) } From d79c286b8ccb41f61d89a130186408f626074f14 Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Tue, 20 Feb 2024 18:31:09 +0200 Subject: [PATCH 15/24] remove the navigation edit button because it leads to a useless screen (#59211) --- packages/edit-site/src/hooks/index.js | 1 - .../src/hooks/navigation-menu-edit.js | 92 ------------------- 2 files changed, 93 deletions(-) delete mode 100644 packages/edit-site/src/hooks/navigation-menu-edit.js diff --git a/packages/edit-site/src/hooks/index.js b/packages/edit-site/src/hooks/index.js index 4e871f4e3824e..513634c55b8f0 100644 --- a/packages/edit-site/src/hooks/index.js +++ b/packages/edit-site/src/hooks/index.js @@ -4,4 +4,3 @@ import './components'; import './push-changes-to-global-styles'; import './template-part-edit'; -import './navigation-menu-edit'; diff --git a/packages/edit-site/src/hooks/navigation-menu-edit.js b/packages/edit-site/src/hooks/navigation-menu-edit.js deleted file mode 100644 index 8b502f075430b..0000000000000 --- a/packages/edit-site/src/hooks/navigation-menu-edit.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * WordPress dependencies - */ -import { __ } from '@wordpress/i18n'; -import { useSelect } from '@wordpress/data'; -import { BlockControls, useBlockEditingMode } from '@wordpress/block-editor'; -import { store as coreStore } from '@wordpress/core-data'; -import { ToolbarButton } from '@wordpress/components'; -import { addFilter } from '@wordpress/hooks'; -import { createHigherOrderComponent } from '@wordpress/compose'; -import { privateApis as routerPrivateApis } from '@wordpress/router'; - -/** - * Internal dependencies - */ -import { useLink } from '../components/routes/link'; -import { unlock } from '../lock-unlock'; -import { NAVIGATION_POST_TYPE } from '../utils/constants'; - -const { useLocation } = unlock( routerPrivateApis ); - -function NavigationMenuEdit( { attributes } ) { - const { ref } = attributes; - const { params } = useLocation(); - const blockEditingMode = useBlockEditingMode(); - const navigationMenu = useSelect( - ( select ) => { - return select( coreStore ).getEntityRecord( - 'postType', - NAVIGATION_POST_TYPE, - // Ideally this should be an official public API. - ref - ); - }, - [ ref ] - ); - - const linkProps = useLink( - { - postId: navigationMenu?.id, - postType: navigationMenu?.type, - canvas: 'edit', - }, - { - // this applies to Navigation Menus as well. - fromTemplateId: params.postId || navigationMenu?.id, - } - ); - - // A non-default setting for block editing mode indicates that the - // editor should restrict "editing" actions. Therefore the `Edit` button - // should not be displayed. - if ( ! navigationMenu || blockEditingMode !== 'default' ) { - return null; - } - - return ( - - { - linkProps.onClick( event ); - } } - > - { __( 'Edit' ) } - - - ); -} - -export const withEditBlockControls = createHigherOrderComponent( - ( BlockEdit ) => ( props ) => { - const { attributes, name } = props; - const isDisplayed = name === 'core/navigation' && attributes.ref; - - return ( - <> - - { isDisplayed && ( - - ) } - - ); - }, - 'withEditBlockControls' -); - -addFilter( - 'editor.BlockEdit', - 'core/edit-site/navigation-edit-button', - withEditBlockControls -); From 55b032fb1af8ff9d0820aae932369dcbf096de77 Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+c4rl0sbr4v0@users.noreply.github.com> Date: Tue, 20 Feb 2024 20:39:24 +0100 Subject: [PATCH 16/24] Interactivity API: Only add proxies to plain objects inside the store (#59039) * Only proxify plain objects * Do not support objects without prototypes * Rename store-tag to interactivity-data * Add test for non-plain objects in state * Update `isObject` implementation * Update changelog --------- Co-authored-by: c4rl0sbr4v0 Co-authored-by: DAreRodz --- .../interactive-blocks/store/block.json | 15 +++++++++++ .../interactive-blocks/store/render.php | 17 +++++++++++++ .../plugins/interactive-blocks/store/view.js | 20 +++++++++++++++ packages/interactivity/CHANGELOG.md | 4 +++ packages/interactivity/src/store.ts | 4 +-- ...tag.spec.ts => interactivity-data.spec.ts} | 0 test/e2e/specs/interactivity/store.spec.ts | 25 +++++++++++++++++++ 7 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 packages/e2e-tests/plugins/interactive-blocks/store/block.json create mode 100644 packages/e2e-tests/plugins/interactive-blocks/store/render.php create mode 100644 packages/e2e-tests/plugins/interactive-blocks/store/view.js rename test/e2e/specs/interactivity/{store-tag.spec.ts => interactivity-data.spec.ts} (100%) create mode 100644 test/e2e/specs/interactivity/store.spec.ts diff --git a/packages/e2e-tests/plugins/interactive-blocks/store/block.json b/packages/e2e-tests/plugins/interactive-blocks/store/block.json new file mode 100644 index 0000000000000..cddd765ba3db5 --- /dev/null +++ b/packages/e2e-tests/plugins/interactive-blocks/store/block.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://schemas.wp.org/trunk/block.json", + "apiVersion": 2, + "name": "test/store", + "title": "E2E Interactivity tests - store definition", + "category": "text", + "icon": "heart", + "description": "", + "supports": { + "interactivity": true + }, + "textdomain": "e2e-interactivity", + "viewScript": "store-view", + "render": "file:./render.php" +} diff --git a/packages/e2e-tests/plugins/interactive-blocks/store/render.php b/packages/e2e-tests/plugins/interactive-blocks/store/render.php new file mode 100644 index 0000000000000..295872137dbda --- /dev/null +++ b/packages/e2e-tests/plugins/interactive-blocks/store/render.php @@ -0,0 +1,17 @@ + + +
+
+
diff --git a/packages/e2e-tests/plugins/interactive-blocks/store/view.js b/packages/e2e-tests/plugins/interactive-blocks/store/view.js new file mode 100644 index 0000000000000..b4a987b5e85b5 --- /dev/null +++ b/packages/e2e-tests/plugins/interactive-blocks/store/view.js @@ -0,0 +1,20 @@ +/** + * WordPress dependencies + */ +import { store, getElement } from '@wordpress/interactivity'; + + +const { state } = store( 'test/store', { + state: { + get isNotProxified() { + const { ref } = getElement(); + return state.elementRef === ref; + } + }, + callbacks: { + init() { + const { ref } = getElement(); + state.elementRef = ref; // HTMLElement + } + } +} ) diff --git a/packages/interactivity/CHANGELOG.md b/packages/interactivity/CHANGELOG.md index 4312571046bbf..0f905e735edf8 100644 --- a/packages/interactivity/CHANGELOG.md +++ b/packages/interactivity/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Bug Fixes + +- Only add proxies to plain objects inside the store. ([#59039](https://github.com/WordPress/gutenberg/pull/59039)) + ## 5.0.0 (2024-02-09) ### New Features diff --git a/packages/interactivity/src/store.ts b/packages/interactivity/src/store.ts index 3b877dac2d414..bbdb167054e3b 100644 --- a/packages/interactivity/src/store.ts +++ b/packages/interactivity/src/store.ts @@ -16,8 +16,8 @@ import { resetNamespace, } from './hooks'; -const isObject = ( item: unknown ): boolean => - !! item && typeof item === 'object' && ! Array.isArray( item ); +const isObject = ( item: unknown ): item is Record< string, unknown > => + item && typeof item === 'object' && item.constructor === Object; const deepMerge = ( target: any, source: any ) => { if ( isObject( target ) && isObject( source ) ) { diff --git a/test/e2e/specs/interactivity/store-tag.spec.ts b/test/e2e/specs/interactivity/interactivity-data.spec.ts similarity index 100% rename from test/e2e/specs/interactivity/store-tag.spec.ts rename to test/e2e/specs/interactivity/interactivity-data.spec.ts diff --git a/test/e2e/specs/interactivity/store.spec.ts b/test/e2e/specs/interactivity/store.spec.ts new file mode 100644 index 0000000000000..a97cf8c055be1 --- /dev/null +++ b/test/e2e/specs/interactivity/store.spec.ts @@ -0,0 +1,25 @@ +/** + * Internal dependencies + */ +import { test, expect } from './fixtures'; + +test.describe( 'data-wp-bind', () => { + test.beforeAll( async ( { interactivityUtils: utils } ) => { + await utils.activatePlugins(); + await utils.addPostWithBlock( 'test/store' ); + } ); + + test.beforeEach( async ( { interactivityUtils: utils, page } ) => { + await page.goto( utils.getLink( 'test/store' ) ); + } ); + + test.afterAll( async ( { interactivityUtils: utils } ) => { + await utils.deactivatePlugins(); + await utils.deleteAllPosts(); + } ); + + test( 'non-plain objects are not proxified', async ( { page } ) => { + const el = page.getByTestId( 'non-plain object' ); + await expect( el ).toHaveText( 'true' ); + } ); +} ); From 3888f1e58528be5a641621ab171eba9f1e816928 Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+c4rl0sbr4v0@users.noreply.github.com> Date: Tue, 20 Feb 2024 20:45:50 +0100 Subject: [PATCH 17/24] Interactivity API docs: Fix WP version, update new store docs (#59107) * Fix WP version, update new store docs * Address changes * Remove not needed note Co-authored-by: c4rl0sbr4v0 Co-authored-by: SantosGuillamot --- .../interactivity/docs/1-getting-started.md | 6 ++--- .../interactivity/docs/2-api-reference.md | 25 ++++++------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/packages/interactivity/docs/1-getting-started.md b/packages/interactivity/docs/1-getting-started.md index 7d8bb8ba23cb2..4e8c1086da695 100644 --- a/packages/interactivity/docs/1-getting-started.md +++ b/packages/interactivity/docs/1-getting-started.md @@ -51,15 +51,13 @@ At this point you should be able to insert the "My First Interactive Block" bloc To start working with the Interactivity API you'll need to have a [proper WordPress development environment for blocks](https://developer.wordpress.org/block-editor/getting-started/devenv/) and some specific code in your block, which should include: -#### A local WordPress installation +#### A local 6.5 WordPress installation You can use [the tools to set your local WordPress environment](https://developer.wordpress.org/block-editor/getting-started/devenv/#wordpress-development-site) you feel more comfortable with. To get quickly started, [`wp-now`](https://www.npmjs.com/package/@wp-now/wp-now) is the easiest way to get a WordPress site up and running locally. -#### Latest vesion of Gutenberg - -The Interactivity API is currently only available as an experimental feature from Gutenberg, so you'll need to have Gutenberg 17.5 or higher version installed and activated in your WordPress installation. +Interactivity API is included in Core in WordPress 6.5, for versions below, you'll need to have Gutenberg 17.5 or higher version installed and activated in your WordPress installation. #### Node.js diff --git a/packages/interactivity/docs/2-api-reference.md b/packages/interactivity/docs/2-api-reference.md index 285b9ea152a41..fa06bae4fedf8 100644 --- a/packages/interactivity/docs/2-api-reference.md +++ b/packages/interactivity/docs/2-api-reference.md @@ -917,40 +917,31 @@ store( "myPlugin", { #### On the server side -> **Note** -> We will rename `wp_store` to `wp_initial_state` in a future version. - -The state can also be initialized on the server using the `wp_store()` function. You would typically do this in the `render.php` file of your block (the `render.php` templates were [introduced](https://make.wordpress.org/core/2022/10/12/block-api-changes-in-wordpress-6-1/) in WordPress 6.1). +The state can also be initialized on the server using the `wp_interactivity_state()` function. You would typically do this in the `render.php` file of your block (the `render.php` templates were [introduced](https://make.wordpress.org/core/2022/10/12/block-api-changes-in-wordpress-6-1/) in WordPress 6.1). -The state defined on the server with `wp_store()` gets merged with the stores defined in the view.js files. +The state defined on the server with `wp_interactivity_state()` gets merged with the stores defined in the view.js files. -The `wp_store` function receives an [associative array](https://www.php.net/manual/en/language.types.array.php) as a parameter. +The `wp_interactivity_state` function receives two arguments, a `string` with the namespace that will be used as a reference and an [associative array](https://www.php.net/manual/en/language.types.array.php) containing the values. _Example of store initialized from the server with a `state` = `{ someValue: 123 }`_ ```php // render.php -wp_store( array( - 'myPlugin' => array( - 'someValue' = 123 - ) -); +wp_interactivity_state( 'myPlugin', array ( + 'someValue' => get_some_value() +)); ``` Initializing the state in the server also allows you to use any WordPress API. For example, you could use the Core Translation API to translate part of your state: ```php // render.php -wp_store( - array( - "favoriteMovies" => array( +wp_interactivity_state( 'favoriteMovies', array( "1" => array( "id" => "123-abc", "movieName" => __("someMovieName", "textdomain") ), - ), - ) -); +) ); ``` ### Private stores From 81805083871fa3420eb4e2a8cdfcb018ae85bd9f Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Wed, 21 Feb 2024 09:50:12 +1000 Subject: [PATCH 18/24] Elements: Make editor selector match theme.json and frontend (#59167) --- .../global-styles/test/use-global-styles-output.js | 5 +++-- packages/blocks/src/api/constants.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/test/use-global-styles-output.js b/packages/block-editor/src/components/global-styles/test/use-global-styles-output.js index dd2b382f89582..f7655f099544a 100644 --- a/packages/block-editor/src/components/global-styles/test/use-global-styles-output.js +++ b/packages/block-editor/src/components/global-styles/test/use-global-styles-output.js @@ -169,7 +169,8 @@ describe( 'global styles renderer', () => { }, }, }, - selector: '.my-heading1 a, .my-heading2 a', + selector: + '.my-heading1 a:where(:not(.wp-element-button)), .my-heading2 a:where(:not(.wp-element-button))', }, { styles: { @@ -480,7 +481,7 @@ describe( 'global styles renderer', () => { expect( toStyles( tree, blockSelectors ) ).toEqual( 'body {margin: 0;}body .is-layout-flow > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }body .is-layout-flow > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }body .is-layout-flow > .aligncenter { margin-left: auto !important; margin-right: auto !important; }body .is-layout-constrained > .alignleft { float: left; margin-inline-start: 0; margin-inline-end: 2em; }body .is-layout-constrained > .alignright { float: right; margin-inline-start: 2em; margin-inline-end: 0; }body .is-layout-constrained > .aligncenter { margin-left: auto !important; margin-right: auto !important; }body .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) { max-width: var(--wp--style--global--content-size); margin-left: auto !important; margin-right: auto !important; }body .is-layout-constrained > .alignwide { max-width: var(--wp--style--global--wide-size); }body .is-layout-flex { display:flex; }body .is-layout-flex { flex-wrap: wrap; align-items: center; }body .is-layout-flex > * { margin: 0; }body .is-layout-grid { display:grid; }body .is-layout-grid > * { margin: 0; }' + - 'body{background-color: red;margin: 10px;padding: 10px;}a{color: blue;}a:hover{color: orange;}a:focus{color: orange;}h1{font-size: 42px;}.wp-block-group{margin-top: 10px;margin-right: 20px;margin-bottom: 30px;margin-left: 40px;padding-top: 11px;padding-right: 22px;padding-bottom: 33px;padding-left: 44px;}h1,h2,h3,h4,h5,h6{color: orange;}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color: hotpink;}h1 a:hover,h2 a:hover,h3 a:hover,h4 a:hover,h5 a:hover,h6 a:hover{color: red;}h1 a:focus,h2 a:focus,h3 a:focus,h4 a:focus,h5 a:focus,h6 a:focus{color: red;}' + + 'body{background-color: red;margin: 10px;padding: 10px;}a:where(:not(.wp-element-button)){color: blue;}a:where(:not(.wp-element-button)):hover{color: orange;}a:where(:not(.wp-element-button)):focus{color: orange;}h1{font-size: 42px;}.wp-block-group{margin-top: 10px;margin-right: 20px;margin-bottom: 30px;margin-left: 40px;padding-top: 11px;padding-right: 22px;padding-bottom: 33px;padding-left: 44px;}h1,h2,h3,h4,h5,h6{color: orange;}h1 a:where(:not(.wp-element-button)),h2 a:where(:not(.wp-element-button)),h3 a:where(:not(.wp-element-button)),h4 a:where(:not(.wp-element-button)),h5 a:where(:not(.wp-element-button)),h6 a:where(:not(.wp-element-button)){color: hotpink;}h1 a:where(:not(.wp-element-button)):hover,h2 a:where(:not(.wp-element-button)):hover,h3 a:where(:not(.wp-element-button)):hover,h4 a:where(:not(.wp-element-button)):hover,h5 a:where(:not(.wp-element-button)):hover,h6 a:where(:not(.wp-element-button)):hover{color: red;}h1 a:where(:not(.wp-element-button)):focus,h2 a:where(:not(.wp-element-button)):focus,h3 a:where(:not(.wp-element-button)):focus,h4 a:where(:not(.wp-element-button)):focus,h5 a:where(:not(.wp-element-button)):focus,h6 a:where(:not(.wp-element-button)):focus{color: red;}' + '.wp-block-image img, .wp-block-image .wp-crop-area{border-radius: 9999px;}.wp-block-image{color: red;}.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }' + '.has-white-color{color: var(--wp--preset--color--white) !important;}.has-white-background-color{background-color: var(--wp--preset--color--white) !important;}.has-white-border-color{border-color: var(--wp--preset--color--white) !important;}.has-black-color{color: var(--wp--preset--color--black) !important;}.has-black-background-color{background-color: var(--wp--preset--color--black) !important;}.has-black-border-color{border-color: var(--wp--preset--color--black) !important;}h1.has-blue-color,h2.has-blue-color,h3.has-blue-color,h4.has-blue-color,h5.has-blue-color,h6.has-blue-color{color: var(--wp--preset--color--blue) !important;}h1.has-blue-background-color,h2.has-blue-background-color,h3.has-blue-background-color,h4.has-blue-background-color,h5.has-blue-background-color,h6.has-blue-background-color{background-color: var(--wp--preset--color--blue) !important;}h1.has-blue-border-color,h2.has-blue-border-color,h3.has-blue-border-color,h4.has-blue-border-color,h5.has-blue-border-color,h6.has-blue-border-color{border-color: var(--wp--preset--color--blue) !important;}' ); diff --git a/packages/blocks/src/api/constants.js b/packages/blocks/src/api/constants.js index 99de83353166c..7062c98404a2a 100644 --- a/packages/blocks/src/api/constants.js +++ b/packages/blocks/src/api/constants.js @@ -257,7 +257,7 @@ export const __EXPERIMENTAL_STYLE_PROPERTY = { }; export const __EXPERIMENTAL_ELEMENTS = { - link: 'a', + link: 'a:where(:not(.wp-element-button))', heading: 'h1, h2, h3, h4, h5, h6', h1: 'h1', h2: 'h2', From c253751a7ba3ed755ab9be9554671c2c034baa43 Mon Sep 17 00:00:00 2001 From: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Date: Wed, 21 Feb 2024 13:52:16 +1100 Subject: [PATCH 19/24] Cover block: clear the min height field when aspect ratio is set (#59191) * Cover block: empty min height field when an aspect ratio is set * Tidy things slightly Co-authored-by: andrewserong Co-authored-by: aaronrobertshaw --- packages/block-library/src/cover/edit/inspector-controls.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/cover/edit/inspector-controls.js b/packages/block-library/src/cover/edit/inspector-controls.js index 889ce3716b963..634e99dc2d98d 100644 --- a/packages/block-library/src/cover/edit/inspector-controls.js +++ b/packages/block-library/src/cover/edit/inspector-controls.js @@ -308,7 +308,11 @@ export default function CoverInspectorControls( { panelId={ clientId } > setAttributes( { From 45c03ac3cc9fba28ece589378dabf8bfcdaef2d2 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 21 Feb 2024 08:59:05 +0400 Subject: [PATCH 20/24] Set the 'defaultBlock' setting for Columns & List blocks (#59196) Co-authored-by: Mamaduka Co-authored-by: ramonjd --- packages/block-library/src/columns/edit.js | 6 ++++++ packages/block-library/src/list/edit.js | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index 95e0ba43efb43..0a756b34c6ef6 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -40,6 +40,10 @@ import { toWidthPrecision, } from './utils'; +const DEFAULT_BLOCK = { + name: 'core/column', +}; + function ColumnsEditContainer( { attributes, setAttributes, clientId } ) { const { isStackedOnMobile, verticalAlignment, templateLock } = attributes; const { count, canInsertColumnBlock, minCount } = useSelect( @@ -90,6 +94,8 @@ function ColumnsEditContainer( { attributes, setAttributes, clientId } ) { className: classes, } ); const innerBlocksProps = useInnerBlocksProps( blockProps, { + defaultBlock: DEFAULT_BLOCK, + directInsert: true, orientation: 'horizontal', renderAppender: false, templateLock, diff --git a/packages/block-library/src/list/edit.js b/packages/block-library/src/list/edit.js index ad294de93e77b..94a7a0945d629 100644 --- a/packages/block-library/src/list/edit.js +++ b/packages/block-library/src/list/edit.js @@ -29,6 +29,9 @@ import OrderedListSettings from './ordered-list-settings'; import { migrateToListV2 } from './utils'; import TagName from './tag-name'; +const DEFAULT_BLOCK = { + name: 'core/list-item', +}; const TEMPLATE = [ [ 'core/list-item' ] ]; const NATIVE_MARGIN_SPACING = 8; @@ -125,6 +128,8 @@ export default function Edit( { attributes, setAttributes, clientId, style } ) { } ); const innerBlocksProps = useInnerBlocksProps( blockProps, { + defaultBlock: DEFAULT_BLOCK, + directInsert: true, template: TEMPLATE, templateLock: false, templateInsertUpdatesSelection: true, From 09dc127240a03f3bd27479b52ccfb6b18eb7738b Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Wed, 21 Feb 2024 14:12:37 +0900 Subject: [PATCH 21/24] Block Mover: Unify visual separator when show button label is on (#59158) Co-authored-by: t-hamano Co-authored-by: aaronrobertshaw Co-authored-by: afercia --- .../src/components/block-toolbar/style.scss | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/block-toolbar/style.scss b/packages/block-editor/src/components/block-toolbar/style.scss index 81dbb98528a84..102594c004aff 100644 --- a/packages/block-editor/src/components/block-toolbar/style.scss +++ b/packages/block-editor/src/components/block-toolbar/style.scss @@ -207,17 +207,18 @@ } } - .block-editor-block-mover .block-editor-block-mover__move-button-container { - width: auto; - - @include break-small() { + .block-editor-block-mover { + .block-editor-block-mover__move-button-container { + width: auto; position: relative; + } - &::before { + &:not(.is-horizontal) .block-editor-block-mover__move-button-container::before { + @include break-small() { content: ""; height: $border-width; width: 100%; - background: $gray-900; + background: $gray-200; position: absolute; top: 50%; left: 50%; @@ -226,6 +227,10 @@ transform: translate(-50%, 0); margin-top: -$border-width * 0.5; } + + @include break-medium { + background: $gray-900; + } } } From a04a8e94e8b93ba60441c6534e21f4c3c26ff1bc Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Wed, 21 Feb 2024 14:54:43 +0800 Subject: [PATCH 22/24] Fix resetting individual blocks to empty values for Pattern Overrides (#59170) Co-authored-by: kevin940726 Co-authored-by: aaronrobertshaw Co-authored-by: talldan --- .../src/components/reset-overrides-control.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/patterns/src/components/reset-overrides-control.js b/packages/patterns/src/components/reset-overrides-control.js index 03d520d2e9b81..586f460835234 100644 --- a/packages/patterns/src/components/reset-overrides-control.js +++ b/packages/patterns/src/components/reset-overrides-control.js @@ -59,7 +59,19 @@ export default function ResetOverridesControl( props ) { const blocks = editedRecord.blocks ?? parse( editedRecord.content ); const block = recursivelyFindBlockWithId( blocks, id ); - props.setAttributes( block.attributes ); + const newAttributes = Object.assign( + // Reset every existing attribute to undefined. + Object.fromEntries( + Object.keys( props.attributes ).map( ( key ) => [ + key, + undefined, + ] ) + ), + // Then assign the original attributes. + block.attributes + ); + + props.setAttributes( newAttributes ); }; return ( From 1eadcb95e30bd9dc89adad9e7599b3411610225d Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 21 Feb 2024 15:01:03 +0400 Subject: [PATCH 23/24] Editor: Remove unused selector value from 'PostTitle' (#59204) Co-authored-by: Mamaduka Co-authored-by: getdave --- packages/editor/src/components/post-title/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/editor/src/components/post-title/index.js b/packages/editor/src/components/post-title/index.js index 0c3dbbf7349a1..cbb2d10eff661 100644 --- a/packages/editor/src/components/post-title/index.js +++ b/packages/editor/src/components/post-title/index.js @@ -25,7 +25,6 @@ import { __unstableStripHTML as stripHTML } from '@wordpress/dom'; /** * Internal dependencies */ -import { store as editorStore } from '../../store'; import { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants'; import usePostTitleFocus from './use-post-title-focus'; import usePostTitle from './use-post-title'; @@ -33,13 +32,11 @@ import PostTypeSupportCheck from '../post-type-support-check'; function PostTitle( _, forwardedRef ) { const { placeholder, hasFixedToolbar } = useSelect( ( select ) => { - const { getEditedPostAttribute } = select( editorStore ); const { getSettings } = select( blockEditorStore ); const { titlePlaceholder, hasFixedToolbar: _hasFixedToolbar } = getSettings(); return { - title: getEditedPostAttribute( 'title' ), placeholder: titlePlaceholder, hasFixedToolbar: _hasFixedToolbar, }; From b7e936b9cd80ca94cec56fedf2c22df994139d7a Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Wed, 21 Feb 2024 22:37:14 +0900 Subject: [PATCH 24/24] env: Fix mariadb version to LTS (#59237) * env: Fix mariadb version to LTS * Update changelog Co-authored-by: t-hamano Co-authored-by: swissspidy Co-authored-by: youknowriad Co-authored-by: jonathanbossenger Co-authored-by: ravinderk --- packages/env/CHANGELOG.md | 4 ++++ packages/env/lib/build-docker-compose-config.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/env/CHANGELOG.md b/packages/env/CHANGELOG.md index ca7d77adfe7bf..502b7e43bd206 100644 --- a/packages/env/CHANGELOG.md +++ b/packages/env/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Bug fix + +- Fix `mariadb` version to LTS [#59237](https://github.com/WordPress/gutenberg/pull/59237) + ## 9.3.0 (2024-02-09) ## 9.2.0 (2024-01-24) diff --git a/packages/env/lib/build-docker-compose-config.js b/packages/env/lib/build-docker-compose-config.js index 5336f8690cca8..1794f7217ff94 100644 --- a/packages/env/lib/build-docker-compose-config.js +++ b/packages/env/lib/build-docker-compose-config.js @@ -172,7 +172,7 @@ module.exports = function buildDockerComposeConfig( config ) { version: '3.7', services: { mysql: { - image: 'mariadb', + image: 'mariadb:lts', ports: [ '3306' ], environment: { MYSQL_ROOT_HOST: '%', @@ -183,7 +183,7 @@ module.exports = function buildDockerComposeConfig( config ) { volumes: [ 'mysql:/var/lib/mysql' ], }, 'tests-mysql': { - image: 'mariadb', + image: 'mariadb:lts', ports: [ '3306' ], environment: { MYSQL_ROOT_HOST: '%',