Skip to content

Commit

Permalink
Update/wp6 3 beta3 (#52234)
Browse files Browse the repository at this point in the history
* Footnotes: inscrease selector specificity for anchor (#52179)

* Patterns: Include template parts for custom areas in Uncategorized category (#52159)

* Fix custom patterns console error (#51947)

* Fix error with react list key with new custom patterns list in inserter

* Update placeholder key

* Add comment to explain the different keys

* Patterns: Fix missing custom patterns in patterns explorer (#51889)

* Add custom patterns to pattern explorer

* show custom patterns in the patterns explorer dialog

* remove changes from 51877

* Fix up use of async lists

* remove a bit of code duplication by adding a new hook

* add 51877 fix back to make testing easier

* Just assign the key value in one place

* Refactor the custom patterns to use the usePatternsState hook

* Fix use of async list

* Translate strings and remove unneeded fields from pattern object

* Try integrating unsynced patterns directly into pattern selectors (#51955)

* Include reusable blocks with an undefined sync status in inserter items

* Update docs

* Remove change to hover dependencies

---------

Co-authored-by: Daniel Richards <daniel.richards@automattic.com>

* i18n: Add context to the word "Filters" (#52198)

* Update home template icon (#52075)

* Centralise all permissions lookup in Link UI and enable (#52166)

* BlockRemovalWarningModal: Fix incorrect '_n' usage (#52164)

* Fix fetching Nav fallback ID flushing Navigation entity cache (#52069)

* Only flush the `getEntityRecords` cache if the fallback isn’t already in state

* Save the edited entity record to a const and then invert it to determine whether we should invalidate the recordds

---------

Co-authored-by: scruffian <ben@scruffian.com>

* Block Editor: Unify texts for Create pattern modal (#52151)

* Fix history back after entering edit mode from Patterns (#52112)

* Add template part icons to the library grid items (#51963)

* Patterns: Fix sidebar tab label (#51953)

* Patterns: Fix setting of sync status for fully synced patterns (#51952)

* Library: Reinstate manage all template parts page (#51961)

* Command Palette: fix incorrect path and snackbar message when template part is deleted (#52034)

* Command Center: Fix incorrect navigation when deleting template part

* removeTemplate: consider title type

* Drop-indicator: remove white border. (#52122)

* Make Navigation fallback selector private (#51413)

* Move selector to become private

* adds basic lock functionality

* remove useless lock-unlock file

* map private selectors to resolvers

* Unlock the other usage

* only create one fallback per session

* Fix core-data duplicate private opt-in

* Data: bind resolvers to selectors individually, support private selectors

---------

Co-authored-by: Andrei Draganescu <andrei.draganescu@automattic.com>
Co-authored-by: scruffian <ben@scruffian.com>
Co-authored-by: Jarda Snajdr <jsnajdr@gmail.com>

* Focus Mode: Use the symbol icon if a pattern is being edited (#52031)

* Footnotes: register meta field for pages (#52024)

* Fix unintentional toggling on of distraction free (#52090)

* replace toggle with set preference - because I don't read code properly it seems

* remove notification

* Revert "Updating social link attributes (#51997)" (#52019)

This reverts commit c711e2a.

* Update home template name (#52048)

* Removes unused call (#51988)

* Remove ability for user to toggle sync status after pattern creation (#51998)

* Fix disable DFM when opening styles command (#52165)

* Update custom patterns label to 'My patterns' (#51949)

* rename custom patterns to my patterns

* Add my patterns label to inserter and show at the top

---------

Co-authored-by: Daniel Richards <daniel.richards@automattic.com>

* Library: Add sync status to pattern details screen (#51954)

* Patterns: Rename Library to Patterns (#52102)

* [Library] Add lock icon for theme patterns (#51990)

* Add lock icon for theme patterns

* Change to class names

* Add aria-description

* Change wording

* Patterns: Use "detached" copy consistently (#51993)

* Editor initrial appender: Zero out margins in constrained layouts. (#52026)

* Update pattern creation modal in library (#51946)

* Fix missing snackbars in Library (#52021)

* Make the entire preview clickable in order to enter "edit" mode in focus mode (#51973)

* Page Content Focus: Add welcome guides (#52014)

* Page Content Focus: Add welcome guides

* Don't show when editor guide is active

* Just use regular accent/theme color in all guides

* slight copy change page guide

* Update components changelog

* Disable new guides in E2E tests

* Use s.w.org videos

---------

Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>

---------

Co-authored-by: Ella <4710635+ellatrix@users.noreply.github.com>
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
Co-authored-by: Glen Davies <glendaviesnz@users.noreply.github.com>
Co-authored-by: Daniel Richards <daniel.richards@automattic.com>
Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
Co-authored-by: James Koster <james@jameskoster.co.uk>
Co-authored-by: Dave Smith <getdavemail@gmail.com>
Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com>
Co-authored-by: scruffian <ben@scruffian.com>
Co-authored-by: Kai Hao <kevin830726@gmail.com>
Co-authored-by: Carolina Nymark <myazalea@hotmail.com>
Co-authored-by: Joen A <1204802+jasmussen@users.noreply.github.com>
Co-authored-by: Andrei Draganescu <andrei.draganescu@automattic.com>
Co-authored-by: Jarda Snajdr <jsnajdr@gmail.com>
Co-authored-by: Andrei Draganescu <me@andreidraganescu.info>
Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
Co-authored-by: Nik Tsekouras <ntsekouras@outlook.com>
Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>
Co-authored-by: Rich Tabor <hi@richtabor.com>
Co-authored-by: Robert Anderson <robert@noisysocks.com>
  • Loading branch information
1 parent bb0b403 commit 6774683
Show file tree
Hide file tree
Showing 94 changed files with 1,009 additions and 642 deletions.
1 change: 0 additions & 1 deletion docs/reference-guides/data/data-core-block-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ _Parameters_
- _state_ `Object`: Editor state.
- _rootClientId_ `?string`: Optional root client ID of block list.
- _syncStatus_ `?string`: Optional sync status to filter pattern blocks by.
_Returns_
Expand Down
12 changes: 0 additions & 12 deletions docs/reference-guides/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,6 @@ _Returns_

- `any`: The entity record's save error.

### getNavigationFallbackId

Retrieve the fallback Navigation.

_Parameters_

- _state_ `State`: Data state.

_Returns_

- `EntityRecordKey | undefined`: The ID for the fallback Navigation post.

### getRawEntityRecord

Returns the entity's record object by key, with its attributes mapped to their raw values.
Expand Down
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.3/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function gutenberg_get_default_block_template_types( $default_template_types ) {
}
if ( isset( $default_template_types['home'] ) ) {
$default_template_types['home'] = array(
'title' => _x( 'Home', 'Template name', 'gutenberg' ),
'title' => _x( 'Blog Home', 'Template name', 'gutenberg' ),
'description' => __(
'Displays the latest posts as either the site homepage or as the "Posts page" as defined under reading settings. If it exists, the Front Page template overrides this template when posts are shown on the homepage.',
'gutenberg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,12 @@ const BlockActionsMenu = ( {
id: 'convertToRegularBlocksOption',
label:
innerBlockCount > 1
? __( 'Convert to regular blocks' )
: __( 'Convert to regular block' ),
? __( 'Detach patterns' )
: __( 'Detach pattern' ),
value: 'convertToRegularBlocksOption',
onSelect: () => {
const successNotice =
innerBlockCount > 1
? /* translators: %s: name of the reusable block */
__( '%s converted to regular blocks' )
: /* translators: %s: name of the reusable block */
__( '%s converted to regular block' );
/* translators: %s: name of the synced block */
const successNotice = __( '%s detached' );
createSuccessNotice(
sprintf(
successNotice,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Button,
__experimentalHStack as HStack,
} from '@wordpress/components';
import { __, _n } from '@wordpress/i18n';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -75,11 +75,9 @@ export function BlockRemovalWarningModal() {
</ul>
) }
<p>
{ _n(
'Removing this block is not advised.',
'Removing these blocks is not advised.',
blockNamesForPrompt.length
) }
{ blockNamesForPrompt.length > 1
? __( 'Removing these blocks is not advised.' )
: __( 'Removing this block is not advised.' ) }
</p>
<HStack justify="right">
<Button variant="tertiary" onClick={ clearRemovalPrompt }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@
opacity: 0.62;
}

// In "constrained" layout containers, the first and last paragraphs have their margins zeroed out.
// In the case of this appender, it needs to apply those same rules to avoid layout shifts.
// Such shifts happen when the bottom margin of the Title block has been set to less than the default 1em margin of paragraphs.
:where(body .is-layout-constrained) & {
> :first-child:first-child {
margin-block-start: 0;
}

// Since this particular appender will only ever appear on an entirely empty document, we don't account for last-child.
}

// Dropzone.
.components-drop-zone__content-icon {
display: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
Flex,
FlexItem,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';
import { useCallback, useMemo } from '@wordpress/element';

/**
Expand Down Expand Up @@ -77,7 +77,7 @@ function FiltersToolsPanel( {

return (
<ToolsPanel
label={ __( 'Filters' ) }
label={ _x( 'Filters', 'Name for applying graphical effects' ) }
resetAll={ resetAll }
panelId={ panelId }
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function PatternList( { filterValue, selectedCategory, patternCategories } ) {
onInsertBlocks,
destinationRootClientId
);

const registeredPatternCategories = useMemo(
() =>
patternCategories.map(
Expand All @@ -75,7 +76,12 @@ function PatternList( { filterValue, selectedCategory, patternCategories } ) {
);
}
return searchItems( allPatterns, filterValue );
}, [ filterValue, selectedCategory, allPatterns ] );
}, [
filterValue,
allPatterns,
selectedCategory,
registeredPatternCategories,
] );

// Announce search results on change.
useEffect( () => {
Expand All @@ -89,7 +95,7 @@ function PatternList( { filterValue, selectedCategory, patternCategories } ) {
count
);
debouncedSpeak( resultsFoundMessage );
}, [ filterValue, debouncedSpeak ] );
}, [ filterValue, debouncedSpeak, filteredBlockPatterns.length ] );

const currentShownPatterns = useAsyncList( filteredBlockPatterns, {
step: INITIAL_INSERTER_RESULTS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
Button,
} from '@wordpress/components';
import { Icon, chevronRight, chevronLeft } from '@wordpress/icons';
import { parse } from '@wordpress/blocks';
import { focus } from '@wordpress/dom';

/**
Expand All @@ -28,13 +27,13 @@ import usePatternsState from './hooks/use-patterns-state';
import BlockPatternList from '../block-patterns-list';
import PatternsExplorerModal from './block-patterns-explorer/explorer';
import MobileTabNavigation from './mobile-tab-navigation';
import useBlockTypesState from './hooks/use-block-types-state';

const noop = () => {};

// Preferred order of pattern categories. Any other categories should
// be at the bottom without any re-ordering.
const patternCategoriesOrder = [
'custom',
'featured',
'posts',
'text',
Expand All @@ -51,18 +50,6 @@ function usePatternsCategories( rootClientId ) {
rootClientId
);

const [ unsyncedPatterns ] = useBlockTypesState(
rootClientId,
undefined,
'unsynced'
);

const filteredUnsyncedPatterns = useMemo( () => {
return unsyncedPatterns.filter(
( { category: unsyncedPatternCategory } ) =>
unsyncedPatternCategory === 'reusable'
);
}, [ unsyncedPatterns ] );
const hasRegisteredCategory = useCallback(
( pattern ) => {
if ( ! pattern.categories || ! pattern.categories.length ) {
Expand Down Expand Up @@ -107,20 +94,9 @@ function usePatternsCategories( rootClientId ) {
label: _x( 'Uncategorized' ),
} );
}
if ( filteredUnsyncedPatterns.length > 0 ) {
categories.push( {
name: 'reusable',
label: _x( 'Custom patterns' ),
} );
}

return categories;
}, [
allCategories,
allPatterns,
filteredUnsyncedPatterns.length,
hasRegisteredCategory,
] );
}, [ allCategories, allPatterns, hasRegisteredCategory ] );

return populatedCategories;
}
Expand Down Expand Up @@ -169,24 +145,6 @@ export function BlockPatternsCategoryPanel( {
onInsert,
rootClientId
);
const [ unsyncedPatterns ] = useBlockTypesState(
rootClientId,
onInsert,
'unsynced'
);
const filteredUnsyncedPatterns = useMemo( () => {
return unsyncedPatterns
.filter(
( { category: unsyncedPatternCategory } ) =>
unsyncedPatternCategory === 'reusable'
)
.map( ( syncedPattern ) => ( {
...syncedPattern,
blocks: parse( syncedPattern.content, {
__unstableSkipMigrationLogs: true,
} ),
} ) );
}, [ unsyncedPatterns ] );

const availableCategories = usePatternsCategories( rootClientId );
const currentCategoryPatterns = useMemo(
Expand All @@ -208,21 +166,15 @@ export function BlockPatternsCategoryPanel( {

return availablePatternCategories.length === 0;
} ),
[ allPatterns, category ]
[ allPatterns, availableCategories, category.name ]
);
const patterns =
category.name === 'reusable'
? filteredUnsyncedPatterns
: currentCategoryPatterns;
const currentShownPatterns = useAsyncList( patterns );

const categoryPatternsList = useAsyncList( currentCategoryPatterns );

// Hide block pattern preview on unmount.
useEffect( () => () => onHover( null ), [] );

if (
! currentCategoryPatterns.length &&
! filteredUnsyncedPatterns.length
) {
if ( ! currentCategoryPatterns.length ) {
return null;
}

Expand All @@ -233,8 +185,8 @@ export function BlockPatternsCategoryPanel( {
</div>
<p>{ category.description }</p>
<BlockPatternList
shownPatterns={ currentShownPatterns }
blockPatterns={ patterns }
shownPatterns={ categoryPatternsList }
blockPatterns={ currentCategoryPatterns }
onClickPattern={ onClick }
onHover={ onHover }
label={ category.label }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ import { store as blockEditorStore } from '../../../store';
*
* @param {string=} rootClientId Insertion's root client ID.
* @param {Function} onInsert function called when inserter a list of blocks.
* @param {?string} syncStatus Optional sync status to filter pattern blocks by.
* @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler)
*/
const useBlockTypesState = ( rootClientId, onInsert, syncStatus ) => {
const useBlockTypesState = ( rootClientId, onInsert ) => {
const { categories, collections, items } = useSelect(
( select ) => {
const { getInserterItems } = select( blockEditorStore );
Expand All @@ -31,10 +30,10 @@ const useBlockTypesState = ( rootClientId, onInsert, syncStatus ) => {
return {
categories: getCategories(),
collections: getCollections(),
items: getInserterItems( rootClientId, syncStatus ),
items: getInserterItems( rootClientId ),
};
},
[ rootClientId, syncStatus ]
[ rootClientId ]
);

const onSelectItem = useCallback(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { useCallback } from '@wordpress/element';
import { useCallback, useMemo } from '@wordpress/element';
import { cloneBlock } from '@wordpress/blocks';
import { useDispatch, useSelect } from '@wordpress/data';
import { __, sprintf } from '@wordpress/i18n';
Expand All @@ -12,6 +12,12 @@ import { store as noticesStore } from '@wordpress/notices';
*/
import { store as blockEditorStore } from '../../../store';

const CUSTOM_CATEGORY = {
name: 'custom',
label: __( 'My patterns' ),
description: __( 'Custom patterns add by site users' ),
};

/**
* Retrieves the block patterns inserter state.
*
Expand All @@ -25,6 +31,7 @@ const usePatternsState = ( onInsert, rootClientId ) => {
( select ) => {
const { __experimentalGetAllowedPatterns, getSettings } =
select( blockEditorStore );

return {
patterns: __experimentalGetAllowedPatterns( rootClientId ),
patternCategories:
Expand All @@ -33,25 +40,34 @@ const usePatternsState = ( onInsert, rootClientId ) => {
},
[ rootClientId ]
);

const allCategories = useMemo(
() => [ ...patternCategories, CUSTOM_CATEGORY ],
[ patternCategories ]
);

const { createSuccessNotice } = useDispatch( noticesStore );
const onClickPattern = useCallback( ( pattern, blocks ) => {
onInsert(
( blocks ?? [] ).map( ( block ) => cloneBlock( block ) ),
pattern.name
);
createSuccessNotice(
sprintf(
/* translators: %s: block pattern title. */
__( 'Block pattern "%s" inserted.' ),
pattern.title
),
{
type: 'snackbar',
}
);
}, [] );

return [ patterns, patternCategories, onClickPattern ];
const onClickPattern = useCallback(
( pattern, blocks ) => {
onInsert(
( blocks ?? [] ).map( ( block ) => cloneBlock( block ) ),
pattern.name
);
createSuccessNotice(
sprintf(
/* translators: %s: block pattern title. */
__( 'Block pattern "%s" inserted.' ),
pattern.title
),
{
type: 'snackbar',
}
);
},
[ createSuccessNotice, onInsert ]
);

return [ patterns, allCategories, onClickPattern ];
};

export default usePatternsState;
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function ReusableBlocksTab( { rootClientId, onInsert, onHover } ) {
post_type: 'wp_block',
} ) }
>
{ __( 'Manage custom patterns' ) }
{ __( 'Manage my patterns' ) }
</Button>
</div>
</>
Expand Down
Loading

0 comments on commit 6774683

Please sign in to comment.