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

First batch of pre-6.3 RC1 updates #52544

Merged
merged 28 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8382196
Site Editor: Restore quick inserter 'Browse all' button (#52529)
Mamaduka Jul 12, 2023
90fbe99
Patterns: update the title of Pattern block in the block inspector ca…
glendaviesnz Jul 12, 2023
3324c2a
Site Editor Pages: load the appropriate template if posts page set (#…
ramonjd Jul 10, 2023
70fb0f9
Allow editing existing footnote from formats toolbar (#52506)
mcsf Jul 11, 2023
5f76704
Block Editor: Display variation icon in the 'BlockDraggable' componen…
Mamaduka Jul 11, 2023
18ce87a
Patterns: add option to set sync status when adding from wp-admin pat…
glendaviesnz Jul 11, 2023
ee99b2a
Revise LinkControl suggestions UI to use MenuItem (#50978)
richtabor Jun 23, 2023
ca85f26
Fix LinkControl mark highlight to bold (#52517)
richtabor Jul 11, 2023
605f510
Add 'reusable' keyword to Pattern blocks (#52543)
noisysocks Jul 13, 2023
9140547
Fix missing Add Template Part button in Template Parts page (#52542)
noisysocks Jul 12, 2023
ecc1eb8
Tweak copy for the reusable block rename hint (#52581)
richtabor Jul 12, 2023
1591f04
Trim footnote anchors from excerpts (#52518)
mcsf Jul 12, 2023
21eb6d5
Site Editor: Reset device preview type when exiting the editing mode …
Mamaduka Jul 12, 2023
10ea6ae
Make "My patterns" permanently visible (#52531)
jameskoster Jul 12, 2023
ae826fd
Hide site hub when resizing frame upwards to avoid overlap (#52180)
jameskoster Jul 12, 2023
00e685b
Fix "Manage all patterns" link appearance (#52532)
jameskoster Jul 12, 2023
e65260e
Update navigation menu title size & weight in detail panels (#52477)
jameskoster Jul 12, 2023
4ce403f
Site Editor Patterns: Ensure sidebar does not shrink when long patter…
andrewserong Jul 12, 2023
298f5b1
Edit Site: Select templateType from the store inside the useSiteEdito…
arthur791004 Jul 14, 2023
0abfe17
Add width to ensure ellipsis is applied (#52575)
richtabor Jul 13, 2023
521b573
Cover Block: Fix block deprecation when fixed background is enabled (…
t-hamano Jul 13, 2023
4df1030
ResizableFrame: Make keyboard accessible (#52443)
mirka Jul 13, 2023
95363ab
Fix importing classic menus (#52573)
draganescu Jul 13, 2023
97afb26
Site Editor: Fix navigation menu sidebar actions order and label (#52…
Mamaduka Jul 13, 2023
f37e6a3
Avoid errors in Dimension visualizers when switching between iframed …
Mamaduka Jul 13, 2023
56a3806
Patterns: Add client side pagination to patterns list (#52538)
glendaviesnz Jul 13, 2023
bd02332
Site Editor: Make sidebar back button go *back* instead of *up* if po…
noisysocks Jul 13, 2023
ebbd078
Adapt template part hint copy (#52527)
richtabor Jul 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Add a user’s avatar. ([Source](https://github.com/WordPress/gutenberg/tree/tru

## Pattern

Create and save content to reuse across your site. Update the block, and the changes apply everywhere it’s used. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/block))
Create and save content to reuse across your site. Update the pattern, and the changes apply everywhere it’s used. ([Source](https://github.com/WordPress/gutenberg/tree/trunk/packages/block-library/src/block))

- **Name:** core/block
- **Category:** reusable
Expand Down
25 changes: 25 additions & 0 deletions lib/compat/wordpress-6.3/footnotes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Compatiblity filters for improved footnotes support.
*
* In core, this could be fixed directly in key functions.
*
* @package gutenberg
*/

/**
* Trims footnote anchors from content.
*
* @param string $content HTML content.
* @return string Filtered content.
*/
function gutenberg_trim_footnotes( $content ) {
if ( ! doing_filter( 'get_the_excerpt' ) ) {
return $content;
}

static $footnote_pattern = '_<sup data-fn="[^"]+" class="[^"]+">\s*<a href="[^"]+" id="[^"]+">\d+</a>\s*</sup>_';
return preg_replace( $footnote_pattern, '', $content );
}

add_filter( 'the_content', 'gutenberg_trim_footnotes' );
1 change: 1 addition & 0 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ function gutenberg_is_experiment_enabled( $name ) {
require_once __DIR__ . '/compat/wordpress-6.3/link-template.php';
require_once __DIR__ . '/compat/wordpress-6.3/block-patterns.php';
require_once __DIR__ . '/compat/wordpress-6.3/class-gutenberg-rest-blocks-controller.php';
require_once __DIR__ . '/compat/wordpress-6.3/footnotes.php';

// Experimental.
if ( ! class_exists( 'WP_Rest_Customizer_Nonces' ) ) {
Expand Down
17 changes: 13 additions & 4 deletions packages/block-editor/src/components/block-draggable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,25 @@ const BlockDraggable = ( {
} ) => {
const { srcRootClientId, isDraggable, icon } = useSelect(
( select ) => {
const { canMoveBlocks, getBlockRootClientId, getBlockName } =
select( blockEditorStore );
const { getBlockType } = select( blocksStore );
const {
canMoveBlocks,
getBlockRootClientId,
getBlockName,
getBlockAttributes,
} = select( blockEditorStore );
const { getBlockType, getActiveBlockVariation } =
select( blocksStore );
const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
const blockName = getBlockName( clientIds[ 0 ] );
const variation = getActiveBlockVariation(
blockName,
getBlockAttributes( clientIds[ 0 ] )
);

return {
srcRootClientId: rootClientId,
isDraggable: canMoveBlocks( clientIds, rootClientId ),
icon: getBlockType( blockName )?.icon,
icon: variation?.icon || getBlockType( blockName )?.icon,
};
},
[ clientIds ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function ReusableBlocksRenameHint() {
<div ref={ ref } className="reusable-blocks-menu-items__rename-hint">
<div className="reusable-blocks-menu-items__rename-hint-content">
{ __(
'Reusable blocks are now called patterns. A synced pattern will behave in exactly the same way as a reusable block.'
'Reusable blocks are now synced patterns. A synced pattern will behave in exactly the same way as a reusable block.'
) }
</div>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { __ } from '@wordpress/i18n';
// order to handle it as a unique case.
export const CREATE_TYPE = '__CREATE__';
export const TEL_TYPE = 'tel';
export const URL_TYPE = 'URL';
export const URL_TYPE = 'link';
export const MAILTO_TYPE = 'mailto';
export const INTERNAL_TYPE = 'internal';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { Button } from '@wordpress/components';
import { MenuItem } from '@wordpress/components';
import { createInterpolateElement } from '@wordpress/element';
import { Icon, plus } from '@wordpress/icons';
import { plus } from '@wordpress/icons';

export const LinkControlSearchCreate = ( {
searchTerm,
onClick,
itemProps,
isSelected,
buttonText,
} ) => {
if ( ! searchTerm ) {
Expand All @@ -40,27 +34,15 @@ export const LinkControlSearchCreate = ( {
}

return (
<Button
<MenuItem
{ ...itemProps }
className={ classnames(
'block-editor-link-control__search-create block-editor-link-control__search-item',
{
'is-selected': isSelected,
}
) }
iconPosition="left"
icon={ plus }
className="block-editor-link-control__search-item"
onClick={ onClick }
>
<Icon
className="block-editor-link-control__search-item-icon"
icon={ plus }
/>

<span className="block-editor-link-control__search-item-header">
<span className="block-editor-link-control__search-item-title">
{ text }
</span>
</span>
</Button>
{ text }
</MenuItem>
);
};

Expand Down
64 changes: 21 additions & 43 deletions packages/block-editor/src/components/link-control/search-item.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
/**
* External dependencies
*/
import classnames from 'classnames';

/**
* WordPress dependencies
*/
import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
import { __ } from '@wordpress/i18n';
import { Button, TextHighlight } from '@wordpress/components';
import { MenuItem, TextHighlight } from '@wordpress/components';
import {
Icon,
globe,
Expand All @@ -19,6 +13,7 @@ import {
file,
} from '@wordpress/icons';
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';

const ICONS_MAP = {
post: postList,
Expand Down Expand Up @@ -52,50 +47,33 @@ function SearchItemIcon( { isURL, suggestion } ) {
export const LinkControlSearchItem = ( {
itemProps,
suggestion,
isSelected = false,
searchTerm,
onClick,
isURL = false,
searchTerm = '',
shouldShowType = false,
} ) => {
const info = isURL
? __( 'Press ENTER to add this link' )
: filterURLForDisplay( safeDecodeURI( suggestion?.url ) );

return (
<Button
<MenuItem
{ ...itemProps }
info={ info }
iconPosition="left"
icon={
<SearchItemIcon suggestion={ suggestion } isURL={ isURL } />
}
onClick={ onClick }
className={ classnames( 'block-editor-link-control__search-item', {
'is-selected': isSelected,
'is-url': isURL,
'is-entity': ! isURL,
} ) }
shortcut={ shouldShowType && getVisualTypeName( suggestion ) }
className="block-editor-link-control__search-item"
>
<SearchItemIcon suggestion={ suggestion } isURL={ isURL } />

<span className="block-editor-link-control__search-item-header">
<span className="block-editor-link-control__search-item-title">
<TextHighlight
// The component expects a plain text string.
text={ stripHTML( suggestion.title ) }
highlight={ searchTerm }
/>
</span>
<span
aria-hidden={ ! isURL }
className="block-editor-link-control__search-item-info"
>
{ ! isURL &&
( filterURLForDisplay(
safeDecodeURI( suggestion.url )
) ||
'' ) }
{ isURL && __( 'Press ENTER to add this link' ) }
</span>
</span>
{ shouldShowType && suggestion.type && (
<span className="block-editor-link-control__search-item-type">
{ getVisualTypeName( suggestion ) }
</span>
) }
</Button>
<TextHighlight
// The component expects a plain text string.
text={ stripHTML( suggestion.title ) }
highlight={ searchTerm }
/>
</MenuItem>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { __, sprintf } from '@wordpress/i18n';
import { VisuallyHidden } from '@wordpress/components';
import { VisuallyHidden, MenuGroup } from '@wordpress/components';

/**
* External dependencies
Expand Down Expand Up @@ -72,59 +72,61 @@ export default function LinkControlSearchResults( {
className={ resultsListClasses }
aria-labelledby={ searchResultsLabelId }
>
{ suggestions.map( ( suggestion, index ) => {
if (
shouldShowCreateSuggestion &&
CREATE_TYPE === suggestion.type
) {
<MenuGroup>
{ suggestions.map( ( suggestion, index ) => {
if (
shouldShowCreateSuggestion &&
CREATE_TYPE === suggestion.type
) {
return (
<LinkControlSearchCreate
searchTerm={ currentInputValue }
buttonText={ createSuggestionButtonText }
onClick={ () =>
handleSuggestionClick( suggestion )
}
// Intentionally only using `type` here as
// the constant is enough to uniquely
// identify the single "CREATE" suggestion.
key={ suggestion.type }
itemProps={ buildSuggestionItemProps(
suggestion,
index
) }
isSelected={ index === selectedSuggestion }
/>
);
}

// If we're not handling "Create" suggestions above then
// we don't want them in the main results so exit early.
if ( CREATE_TYPE === suggestion.type ) {
return null;
}

return (
<LinkControlSearchCreate
searchTerm={ currentInputValue }
buttonText={ createSuggestionButtonText }
onClick={ () =>
handleSuggestionClick( suggestion )
}
// Intentionally only using `type` here as
// the constant is enough to uniquely
// identify the single "CREATE" suggestion.
key={ suggestion.type }
<LinkControlSearchItem
key={ `${ suggestion.id }-${ suggestion.type }` }
itemProps={ buildSuggestionItemProps(
suggestion,
index
) }
suggestion={ suggestion }
index={ index }
onClick={ () => {
handleSuggestionClick( suggestion );
} }
isSelected={ index === selectedSuggestion }
isURL={ LINK_ENTRY_TYPES.includes(
suggestion.type
) }
searchTerm={ currentInputValue }
shouldShowType={ shouldShowSuggestionsTypes }
isFrontPage={ suggestion?.isFrontPage }
/>
);
}

// If we're not handling "Create" suggestions above then
// we don't want them in the main results so exit early.
if ( CREATE_TYPE === suggestion.type ) {
return null;
}

return (
<LinkControlSearchItem
key={ `${ suggestion.id }-${ suggestion.type }` }
itemProps={ buildSuggestionItemProps(
suggestion,
index
) }
suggestion={ suggestion }
index={ index }
onClick={ () => {
handleSuggestionClick( suggestion );
} }
isSelected={ index === selectedSuggestion }
isURL={ LINK_ENTRY_TYPES.includes(
suggestion.type
) }
searchTerm={ currentInputValue }
shouldShowType={ shouldShowSuggestionsTypes }
isFrontPage={ suggestion?.isFrontPage }
/>
);
} ) }
} ) }
</MenuGroup>
</div>
</div>
);
Expand Down