Skip to content

Commit

Permalink
prep build 02/23
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Feb 23, 2022
2 parents 1d047a1 + 2d3f32c commit bf65cbf
Show file tree
Hide file tree
Showing 78 changed files with 2,781 additions and 177 deletions.
277 changes: 277 additions & 0 deletions changelog.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gutenberg",
"version": "12.6.0",
"version": "12.7.0-rc.1",
"private": true,
"description": "A new WordPress editor experience.",
"author": "The WordPress Contributors",
Expand Down
2 changes: 1 addition & 1 deletion packages/annotations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/annotations",
"version": "2.3.1",
"version": "2.3.2",
"description": "Annotate content in the Gutenberg editor.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion packages/block-directory/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/block-directory",
"version": "3.1.2",
"version": "3.1.4",
"description": "Extend editor with block directory features to search, download and install blocks.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
2 changes: 2 additions & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

## 8.2.0 (2022-02-23)

### New Features

- `LineHeightControl`: Changes internal implementation to use `NumberControl`, which allows enhanced interactions such as dragging to change the value. To improve consistency with other control components, the bottom margin styles on the component has been deprecated, and will be removed in a future version. To opt into this simplified margin style, set the `__nextHasNoMarginBottom` prop to `true`.
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/block-editor",
"version": "8.1.1",
"version": "8.2.0",
"description": "Generic block editor.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function LineHeightControl( {
// For example, Firefox emits an input event with inputType="insertReplacementText"
// on spin button clicks, while other browsers do not even emit an input event.
const wasTypedOrPasted = [ 'insertText', 'insertFromPaste' ].includes(
action.payload.event.nativeEvent.inputType
action.payload.event.nativeEvent?.inputType
);
state.value = adjustNextValue( state.value, wasTypedOrPasted );
return state;
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wordpress/block-library",
"version": "7.0.0",
"version": "7.0.2",
"description": "Block library for the WordPress editor.",
"author": "The WordPress Contributors",
"license": "GPL-2.0-or-later",
Expand Down
34 changes: 13 additions & 21 deletions packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
ToolbarGroup,
ToolbarDropdownMenu,
Button,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
Expand Down Expand Up @@ -482,26 +481,18 @@ function Navigation( {
<RecursionProvider>
<BlockControls>
{ ! isDraftNavigationMenu && isEntityAvailable && (
<ToolbarGroup>
<ToolbarDropdownMenu
label={ __( 'Select Menu' ) }
text={ __( 'Select Menu' ) }
icon={ null }
>
{ ( { onClose } ) => (
<NavigationMenuSelector
clientId={ clientId }
onSelect={ ( { id } ) => {
setRef( id );
onClose();
} }
onCreateNew={ startWithEmptyMenu }
/* translators: %s: The name of a menu. */
actionLabel={ __( "Switch to '%s'" ) }
showManageActions
/>
) }
</ToolbarDropdownMenu>
<ToolbarGroup className="wp-block-navigation__toolbar-menu-selector">
<NavigationMenuSelector
currentMenuId={ ref }
clientId={ clientId }
onSelect={ ( { id } ) => {
setRef( id );
} }
onCreateNew={ startWithEmptyMenu }
/* translators: %s: The name of a menu. */
actionLabel={ __( "Switch to '%s'" ) }
showManageActions
/>
</ToolbarGroup>
) }
<ToolbarGroup>{ listViewToolbarButton }</ToolbarGroup>
Expand Down Expand Up @@ -660,6 +651,7 @@ function Navigation( {
<nav { ...blockProps }>
{ isPlaceholderShown && (
<PlaceholderComponent
currentMenuId={ ref }
onFinish={ ( post ) => {
setIsPlaceholderShown( false );
if ( post ) {
Expand Down
153 changes: 93 additions & 60 deletions packages/block-library/src/navigation/edit/navigation-menu-selector.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/**
* WordPress dependencies
*/
import { MenuGroup, MenuItem } from '@wordpress/components';
import {
MenuGroup,
MenuItem,
ToolbarDropdownMenu,
} from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { decodeEntities } from '@wordpress/html-entities';
import { addQueryArgs } from '@wordpress/url';
Expand All @@ -15,11 +19,13 @@ import useConvertClassicMenu from '../use-convert-classic-menu';
import useCreateNavigationMenu from './use-create-navigation-menu';

export default function NavigationMenuSelector( {
currentMenuId,
clientId,
onSelect,
onCreateNew,
showManageActions = false,
actionLabel,
toggleProps = {},
} ) {
/* translators: %s: The name of a menu. */
const createActionLabel = __( "Create from '%s'" );
Expand All @@ -35,6 +41,12 @@ export default function NavigationMenuSelector( {
canSwitchNavigationMenu,
} = useNavigationMenu();

// Avoid showing any currently active menu in the list of
// menus that can be selected.
const navigationMenusOmitCurrent = navigationMenus.filter(
( menu ) => ! currentMenuId || menu.id !== currentMenuId
);

const createNavigationMenu = useCreateNavigationMenu( clientId );

const onFinishMenuCreation = async (
Expand All @@ -56,81 +68,102 @@ export default function NavigationMenuSelector( {
onFinishMenuCreation
);

const hasNavigationMenus = !! navigationMenus?.length;
const hasNavigationMenus = !! navigationMenusOmitCurrent?.length;
const hasClassicMenus = !! classicMenus?.length;
const showNavigationMenus = !! canSwitchNavigationMenu;
const showClassicMenus = !! canUserCreateNavigationMenu;
const hasManagePermissions =
canUserCreateNavigationMenu || canUserUpdateNavigationMenu;

// Show the selector if:
// - has switch or create permissions and there are block or classic menus.
// - user has create or update permisisons and component should show the menu actions.
const showSelectMenus =
( canSwitchNavigationMenu || canUserCreateNavigationMenu ) &&
( hasNavigationMenus || hasClassicMenus );
( ( canSwitchNavigationMenu || canUserCreateNavigationMenu ) &&
( hasNavigationMenus || hasClassicMenus ) ) ||
( hasManagePermissions && showManageActions );

if ( ! showSelectMenus ) {
return null;
}

return (
<>
{ showNavigationMenus && hasNavigationMenus && (
<MenuGroup label={ __( 'Menus' ) }>
{ navigationMenus.map( ( menu ) => {
const label = decodeEntities( menu.title.rendered );
return (
<MenuItem
onClick={ () => {
onSelect( menu );
} }
key={ menu.id }
aria-label={ sprintf( actionLabel, label ) }
>
{ label }
</MenuItem>
);
} ) }
</MenuGroup>
) }
{ showClassicMenus && hasClassicMenus && (
<MenuGroup label={ __( 'Classic Menus' ) }>
{ classicMenus.map( ( menu ) => {
const label = decodeEntities( menu.name );
return (
<ToolbarDropdownMenu
label={ __( 'Select Menu' ) }
text={ __( 'Select Menu' ) }
icon={ null }
toggleProps={ toggleProps }
>
{ ( { onClose } ) => (
<>
{ showNavigationMenus && hasNavigationMenus && (
<MenuGroup label={ __( 'Menus' ) }>
{ navigationMenusOmitCurrent.map( ( menu ) => {
const label = decodeEntities(
menu.title.rendered
);
return (
<MenuItem
onClick={ () => {
onClose();
onSelect( menu );
} }
key={ menu.id }
aria-label={ sprintf(
actionLabel,
label
) }
>
{ label }
</MenuItem>
);
} ) }
</MenuGroup>
) }
{ showClassicMenus && hasClassicMenus && (
<MenuGroup label={ __( 'Classic Menus' ) }>
{ classicMenus.map( ( menu ) => {
const label = decodeEntities( menu.name );
return (
<MenuItem
onClick={ () => {
onClose();
convertClassicMenuToBlocks(
menu.id,
menu.name
);
} }
key={ menu.id }
aria-label={ sprintf(
createActionLabel,
label
) }
>
{ label }
</MenuItem>
);
} ) }
</MenuGroup>
) }

{ showManageActions && hasManagePermissions && (
<MenuGroup label={ __( 'Tools' ) }>
{ canUserCreateNavigationMenu && (
<MenuItem onClick={ onCreateNew }>
{ __( 'Create new menu' ) }
</MenuItem>
) }
<MenuItem
onClick={ () => {
convertClassicMenuToBlocks(
menu.id,
menu.name
);
} }
key={ menu.id }
aria-label={ sprintf(
createActionLabel,
label
) }
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ label }
{ __( 'Manage menus' ) }
</MenuItem>
);
} ) }
</MenuGroup>
) }

{ showManageActions && hasManagePermissions && (
<MenuGroup label={ __( 'Tools' ) }>
{ canUserCreateNavigationMenu && (
<MenuItem onClick={ onCreateNew }>
{ __( 'Create new menu' ) }
</MenuItem>
</MenuGroup>
) }
<MenuItem
href={ addQueryArgs( 'edit.php', {
post_type: 'wp_navigation',
} ) }
>
{ __( 'Manage menus' ) }
</MenuItem>
</MenuGroup>
</>
) }
</>
</ToolbarDropdownMenu>
);
}
Loading

0 comments on commit bf65cbf

Please sign in to comment.