Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/wp6 3 beta3 #52234

Merged
merged 35 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
83ea11f
Footnotes: inscrease selector specificity for anchor (#52179)
ellatrix Jun 30, 2023
2e8830c
Patterns: Include template parts for custom areas in Uncategorized ca…
aaronrobertshaw Jul 3, 2023
db15884
Fix custom patterns console error (#51947)
glendaviesnz Jun 28, 2023
6aaf269
i18n: Add context to the word "Filters" (#52198)
t-hamano Jul 1, 2023
5b1f580
Update home template icon (#52075)
jameskoster Jun 28, 2023
14c54c5
Centralise all permissions lookup in Link UI and enable (#52166)
getdave Jun 30, 2023
0528766
BlockRemovalWarningModal: Fix incorrect '_n' usage (#52164)
Mamaduka Jun 30, 2023
b8229fe
Fix fetching Nav fallback ID flushing Navigation entity cache (#52069)
getdave Jun 29, 2023
ac9cd11
Block Editor: Unify texts for Create pattern modal (#52151)
t-hamano Jun 30, 2023
b0a5943
Fix history back after entering edit mode from Patterns (#52112)
kevin940726 Jun 30, 2023
b64bc8a
Add template part icons to the library grid items (#51963)
carolinan Jun 28, 2023
0702768
Patterns: Fix sidebar tab label (#51953)
aaronrobertshaw Jun 28, 2023
70fda06
Patterns: Fix setting of sync status for fully synced patterns (#51952)
aaronrobertshaw Jun 28, 2023
b59ce7c
Library: Reinstate manage all template parts page (#51961)
aaronrobertshaw Jun 28, 2023
d739511
Command Palette: fix incorrect path and snackbar message when templat…
t-hamano Jun 30, 2023
d4d0106
Drop-indicator: remove white border. (#52122)
jasmussen Jun 29, 2023
7b8db97
Make Navigation fallback selector private (#51413)
getdave Jun 29, 2023
ea6e8c5
Focus Mode: Use the symbol icon if a pattern is being edited (#52031)
carolinan Jun 29, 2023
8064587
Footnotes: register meta field for pages (#52024)
ellatrix Jun 29, 2023
7dbdc17
Fix unintentional toggling on of distraction free (#52090)
draganescu Jun 29, 2023
97e3acf
Revert "Updating social link attributes (#51997)" (#52019)
ramonjd Jun 29, 2023
53c86fc
Update home template name (#52048)
jameskoster Jun 28, 2023
aba35cb
Removes unused call (#51988)
getdave Jun 28, 2023
0ea227a
Remove ability for user to toggle sync status after pattern creation …
glendaviesnz Jun 29, 2023
9d456e4
Fix disable DFM when opening styles command (#52165)
ntsekouras Jun 30, 2023
d45c58c
Update custom patterns label to 'My patterns' (#51949)
SaxonF Jun 28, 2023
28789fc
Library: Add sync status to pattern details screen (#51954)
aaronrobertshaw Jun 28, 2023
b40ea4a
Patterns: Rename Library to Patterns (#52102)
aaronrobertshaw Jun 30, 2023
e29a7c2
[Library] Add lock icon for theme patterns (#51990)
kevin940726 Jun 30, 2023
be810dd
Patterns: Use "detached" copy consistently (#51993)
richtabor Jun 28, 2023
ce47b98
Editor initrial appender: Zero out margins in constrained layouts. (#…
jasmussen Jun 28, 2023
61f8821
Update pattern creation modal in library (#51946)
SaxonF Jun 28, 2023
6271aae
Fix missing snackbars in Library (#52021)
kevin940726 Jun 28, 2023
ad1865a
Make the entire preview clickable in order to enter "edit" mode in fo…
getdave Jun 28, 2023
3efbff4
Page Content Focus: Add welcome guides (#52014)
noisysocks Jul 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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