Skip to content

Commit

Permalink
First batch of pre-6.3 RC1 updates (#52544)
Browse files Browse the repository at this point in the history
* Site Editor: Restore quick inserter 'Browse all' button (#52529)

* Site Editor: Restore quick inserter 'Browse all' button

* Remove leftover comment

* Patterns: update the title of Pattern block in the block inspector card  (#52010)

* Site Editor Pages: load the appropriate template if posts page set (#52266)

* This commit:
- links the posts page to the homepage template when a post page is set
- abstracts logic to get page item props

* The Posts Page resolves to display the Home or Index template only. Adding a check to skip the Front Page

* Showing homepage settings for posts pages that are set as the post page in reading settings

* Post pages that have been set to display posts will redirect to first the home template, then the index template. The fallback is the post id of the page.

* Reverted refactor of packages/edit-site/src/components/sidebar-navigation-screen-page/index.js
Will do it in a follow up

* Allow editing existing footnote from formats toolbar (#52506)

* Block Editor: Display variation icon in the 'BlockDraggable' component (#52502)

* Patterns: add option to set sync status when adding from wp-admin patterns list (#52352)

* Show a modal to set sync status if adding pattern from pattern list page

* Make sure the modal loads if post settings panel not open

* don't load modal component at all if not new post

* Simplify the sync status so undefined always = synced

* Update packages/editor/src/components/post-sync-status/index.js

---------

Co-authored-by: Ramon <[email protected]>

* Revise LinkControl suggestions UI to use MenuItem (#50978)

* Use "link" instead of "URL" for URL_TYPE

* Use MenuItem for search create button

* Use sentence case for "Create page"

* Use a MenuGroup for search results

* Use MenuItem for search item

* Refactoring styles (WIP)

* Preserve whitespace in results text

* Reinstate result item information including permalink

* Remove debugging CSS code

* Reinstate CSS to control size of rich previews favicon

* Remove other commented out CSS code

* Reinstate selected styles

* Remove more redundant CSS

* Add some basic results hover/focus styling.

Needs improving

* Improve icon alignment

* Update tests to handle wording changes

* Remove inconsistent hover/focus style

MenuItem already has hover/focus styles

* Reinstate is-selected visual state

* Update test to make sense in context of #51011

See #51011

* Fix locator for result text

---------

Co-authored-by: Dave Smith <[email protected]>

* Fix LinkControl mark highlight to bold (#52517)

* Add 'reusable' keyword to Pattern blocks (#52543)

* Fix missing Add Template Part button in Template Parts page (#52542)

* Tweak copy for the reusable block rename hint (#52581)

* Trim footnote anchors from excerpts (#52518)

* Trim footnote anchors from excerpts

* Add comments, fix spacing, appease linter

* Site Editor: Reset device preview type when exiting the editing mode (#52566)

* Make "My patterns" permanently visible (#52531)

* Hide site hub when resizing frame upwards to avoid overlap (#52180)

* Fix "Manage all patterns" link appearance (#52532)

* Fix "Manage all patterns" link

* Update focus style

* Update navigation menu title size & weight in detail panels (#52477)

* Update menu title size

* Adjust font weight

* Site Editor Patterns: Ensure sidebar does not shrink when long pattern titles are used (#52547)

* Edit Site: Select templateType from the store inside the useSiteEditorSettings hook (#52503)

* Add width to ensure ellipsis is applied (#52575)

* Cover Block: Fix block deprecation when fixed background is enabled (#51612)

* ResizableFrame: Make keyboard accessible (#52443)

* ResizableFrame: Make keyboard accessible

* Fix outline in Safari

* Use proper CSS modifier

* Add aria-label to button

* Keep handle enlarged when resizing (Safari)

* Add back visually hidden help text

* Don't switch to edit mode

* Make the handle a role="separator"

* Revert to `button`

* Switch description text to `div hidden`

* Prevent keydown event default when right/left arrow

* Change minimum frame width to 320px

* Mention shift key in description text

* Only render resize handle when in View mode

* Fix importing classic menus (#52573)

* use the same create hook for classic import

* Remove redundant arg to hook

---------

Co-authored-by: Dave Smith <[email protected]>

* Site Editor: Fix navigation menu sidebar actions order and label (#52592)

* Avoid errors in Dimension visualizers when switching between iframed and non-iframed editors (#52588)

* Patterns: Add client side pagination to patterns list (#52538)

Co-authored-by: Saxon Fletcher <[email protected]>

* Site Editor: Make sidebar back button go *back* instead of *up* if possible (#52456)

* Navigator: Add replace option to goTo() and goToParent()

* Site Editor: Make sidebar back button go back instead of up if possible

* Adapt template part hint copy (#52527)

* Try "panel" instead of "page"

* Update template-part-hint.js

---------

Co-authored-by: George Mamadashvili <[email protected]>
Co-authored-by: Glen Davies <[email protected]>
Co-authored-by: Ramon <[email protected]>
Co-authored-by: Miguel Fonseca <[email protected]>
Co-authored-by: Rich Tabor <[email protected]>
Co-authored-by: Dave Smith <[email protected]>
Co-authored-by: Robert Anderson <[email protected]>
Co-authored-by: James Koster <[email protected]>
Co-authored-by: Andrew Serong <[email protected]>
Co-authored-by: arthur791004 <[email protected]>
Co-authored-by: Aki Hamano <[email protected]>
Co-authored-by: Lena Morita <[email protected]>
Co-authored-by: Andrei Draganescu <[email protected]>
Co-authored-by: Saxon Fletcher <[email protected]>
  • Loading branch information
15 people committed Jul 14, 2023
1 parent 86ecd96 commit bcef74e
Show file tree
Hide file tree
Showing 52 changed files with 847 additions and 519 deletions.
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
94 changes: 48 additions & 46 deletions packages/block-editor/src/components/link-control/search-results.js
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
Loading

0 comments on commit bcef74e

Please sign in to comment.