Skip to content

Commit

Permalink
prep build 07/30
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Jul 30, 2024
2 parents 2940a11 + 55ddb6f commit d31e13b
Show file tree
Hide file tree
Showing 79 changed files with 874 additions and 546 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ module.exports = {
'RangeControl',
'SearchControl',
'TextareaControl',
'ToggleGroupControl',
'TreeSelect',
].map( ( componentName ) => ( {
selector: `JSXOpeningElement[name.name="${ componentName }"]:not(:has(JSXAttribute[name.name="__nextHasNoMarginBottom"]))`,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-backport-changelog.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Verify Core Backport Changlog
name: Verify Core Backport Changelog

on:
pull_request:
Expand Down
10 changes: 9 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"at-rule-empty-line-before": null,
"at-rule-no-unknown": null,
"comment-empty-line-before": null,
"declaration-property-value-allowed-list": [
{
"flex-direction": "/^(?!(row|column)-reverse).*$/"
},
{
"message": "Avoid the flex-direction reverse values. For accessibility reasons, visual, reading, and DOM order must match. Only use the reverse values when they do not affect reading order, meaning, and interaction."
}
],
"declaration-property-value-disallowed-list": [
{
"/.*/": [ "/--wp-components-color-/" ]
Expand All @@ -18,7 +26,7 @@
"property-disallowed-list": [
[ "order" ],
{
"message": "Avoid the order property. For accessibility reasons, visual, reading, and DOM order must match. Only use the order property when it does not affect reading order, meaning, and interaction"
"message": "Avoid the order property. For accessibility reasons, visual, reading, and DOM order must match. Only use the order property when it does not affect reading order, meaning, and interaction."
}
],
"rule-empty-line-before": null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ We recommend using the [Node Version Manager](https://github.com/nvm-sh/nvm) (nv
We recommend using the [wp-env package](/packages/env/README.md) for setting WordPress environment locally. You'll need to install Docker to use `wp-env`. See the [Development Environment tutorial for additional details](/docs/getting-started/devenv/README.md).
> Note: To install Docker on Windows 10 Home Edition, follow the [install instructions from Docker for Windows with WSL2](https://docs.docker.com/docker-for-windows/wsl/).
As an alternative to Docker setup, you can use [Local](https://localwp.com/), [WampServer](http://www.wampserver.com/en/), or [MAMP](https://www.mamp.info/), or even use a remote server.
As an alternative to Docker setup, you can use [Local](https://localwp.com/), [WampServer](https://wampserver.aviatechno.net/), or [MAMP](https://www.mamp.info/), or even use a remote server.

- GitHub CLI
Although not a requirement, the [GitHub CLI](https://cli.github.com/) can be very useful in helping you checkout pull requests locally. Both from the Gutenberg repo and forked repos. This can be a major time saver while code reviewing and testing pull requests.
Expand Down Expand Up @@ -134,7 +134,7 @@ If you run into an issue, check the [troubleshooting section in `wp-env` documen

### Using Local or MAMP

As an alternative to Docker and `wp-env`, you can also use [Local](https://localwp.com/), [WampServer](http://www.wampserver.com/en/), or [MAMP](https://www.mamp.info/) to run a local WordPress environment. To do so clone and install Gutenberg as a regular plugin in your installation by creating a symlink or copying the directory to the proper `wp-content/plugins` directory.
As an alternative to Docker and `wp-env`, you can also use [Local](https://localwp.com/), [WampServer](https://wampserver.aviatechno.net/), or [MAMP](https://www.mamp.info/) to run a local WordPress environment. To do so clone and install Gutenberg as a regular plugin in your installation by creating a symlink or copying the directory to the proper `wp-content/plugins` directory.

You will also need some extra configuration to be able to run the e2e tests.

Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/core-blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ Introduce new sections and organize content to help visitors (and search engines
- **Name:** core/heading
- **Category:** text
- **Supports:** __unstablePasteTextInline, align (full, wide), anchor, className, color (background, gradients, link, text), interactivity (clientNavigation), spacing (margin, padding), splitting, typography (fontSize, lineHeight)
- **Attributes:** content, level, placeholder, textAlign
- **Attributes:** content, level, levelOptions, placeholder, textAlign

## Home Link

Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/interactivity-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Here you have some more resources to learn/read more about the Interactivity API
- [Interactivity API Discussions](https://github.com/WordPress/gutenberg/discussions/52882), especially the [showcase](https://github.com/WordPress/gutenberg/discussions/55642#discussioncomment-9667164) discussions.
- [wpmovies.dev](http://wpmovies.dev/) demo and its [wp-movies-demo](https://github.com/WordPress/wp-movies-demo) repo
- Examples using the Interactivity API at [block-development-examples](https://github.com/WordPress/block-development-examples):
- [`interactivity-api-block-833d15`](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/833d15)
- [`interactivity-api-block-833d15`](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/interactivity-api-block-833d15)
- [`interactivity-api-countdown-3cd73e`](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/interactivity-api-countdown-3cd73e)
- [`interactivity-api-quiz-1835fa`](https://github.com/WordPress/block-development-examples/tree/trunk/plugins/interactivity-api-quiz-1835fa)

Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/interactivity-api/iapi-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ To summarize, using the Interactivity API rather than just using React comes wit

- If you use React, your interactive blocks must generate the same markup on the client as they do on the server in PHP. Using the Interactivity API, there is no such requirement as directives are added to server-rendered HTML.
- The Interactivity API is PHP-friendlier. It works out of the box with WordPress hooks or other server functionalities such as internationalization. For example, with React, you can’t know which hooks are applied on the server, and their modifications would be overwritten after hydration.
- All the benefits of [using a standard](https://developer.wordpress.org/block-editor/reference-guides/interactivity-api/what-is-interactivity-api#why-a-standard).
- All the benefits of [using a standard](/docs/reference-guides/interactivity-api/iapi-about.md#why-a-standard).


## What are the benefits of Interactivity API over just using jQuery or vanilla JavaScript?
Expand Down
1 change: 0 additions & 1 deletion packages/base-styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ $text-editor-font-size: 15px;
$editor-line-height: 1.8;
$mobile-text-min-font-size: 16px; // Any font size below 16px will cause Mobile Safari to "zoom in".


/**
* Grid System.
* https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import { Button } from '@wordpress/components';
import { useSelect, useDispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { chevronRightSmall, Icon } from '@wordpress/icons';
import { useRef } from '@wordpress/element';

/**
* Internal dependencies
*/
import BlockTitle from '../block-title';
import { store as blockEditorStore } from '../../store';
import { unlock } from '../../lock-unlock';
import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';
import { useBlockElementRef } from '../block-list/use-block-props/use-block-refs';
import getEditorRegion from '../../utils/get-editor-region';

/**
Expand Down Expand Up @@ -41,7 +42,8 @@ function BlockBreadcrumb( { rootLabelText } ) {

// We don't care about this specific ref, but this is a way
// to get a ref within the editor canvas so we can focus it later.
const blockRef = useBlockRef( clientId );
const blockRef = useRef();
useBlockElementRef( clientId, blockRef );

/*
* Disable reason: The `list` ARIA role is redundant but
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/components/block-draggable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { throttle } from '@wordpress/compose';
import BlockDraggableChip from './draggable-chip';
import useScrollWhenDragging from './use-scroll-when-dragging';
import { store as blockEditorStore } from '../../store';
import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';
import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
import { isDropTargetValid } from '../use-block-drop-zone';

const BlockDraggable = ( {
Expand Down Expand Up @@ -82,8 +82,8 @@ const BlockDraggable = ( {
}, [] );

// Find the root of the editor iframe.
const blockRef = useBlockRef( clientIds[ 0 ] );
const editorRoot = blockRef.current?.closest( 'body' );
const blockEl = useBlockElement( clientIds[ 0 ] );
const editorRoot = blockEl?.closest( 'body' );

/*
* Add a dragover event listener to the editor root to track the blocks being dragged over.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
/**
* WordPress dependencies
*/
import {
useContext,
useMemo,
useRef,
useState,
useLayoutEffect,
} from '@wordpress/element';
import { useContext, useState, useLayoutEffect } from '@wordpress/element';
import { useRefEffect } from '@wordpress/compose';

/**
Expand All @@ -16,7 +10,7 @@ import { useRefEffect } from '@wordpress/compose';
import { BlockRefs } from '../../provider/block-refs-provider';

/** @typedef {import('@wordpress/element').RefCallback} RefCallback */
/** @typedef {import('@wordpress/element').RefObject} RefObject */
/** @typedef {import('@wordpress/element').Ref} Ref */

/**
* Provides a ref to the BlockRefs context.
Expand All @@ -36,31 +30,33 @@ export function useBlockRefProvider( clientId ) {
);
}

function assignRef( ref, value ) {
if ( typeof ref === 'function' ) {
ref( value );
} else if ( ref ) {
ref.current = value;
}
}

/**
* Gets a ref pointing to the current block element. Continues to return the same
* stable ref object even if the `clientId` argument changes. This hook is not
* reactive, i.e., it won't trigger a rerender of the calling component if the
* ref value changes. For reactive use cases there is the `useBlockElement` hook.
*
* @param {string} clientId The client ID to get a ref for.
* Tracks the DOM element for the block identified by `clientId` and assigns it to the `ref`
* whenever it changes.
*
* @return {RefObject} A ref containing the element.
* @param {string} clientId The client ID to track.
* @param {Ref} ref The ref object/callback to assign to.
*/
function useBlockRef( clientId ) {
export function useBlockElementRef( clientId, ref ) {
const { refsMap } = useContext( BlockRefs );
const latestClientId = useRef();
latestClientId.current = clientId;

// Always return an object, even if no ref exists for a given client ID, so
// that `current` works at a later point.
return useMemo(
() => ( {
get current() {
return refsMap.get( latestClientId.current ) ?? null;
},
} ),
[ refsMap ]
);
useLayoutEffect( () => {
assignRef( ref, refsMap.get( clientId ) );
const unsubscribe = refsMap.subscribe( clientId, () =>
assignRef( ref, refsMap.get( clientId ) )
);
return () => {
unsubscribe();
assignRef( ref, null );
};
}, [ refsMap, clientId, ref ] );
}

/**
Expand All @@ -71,20 +67,8 @@ function useBlockRef( clientId ) {
*
* @return {Element|null} The block's wrapper element.
*/
function useBlockElement( clientId ) {
const { refsMap } = useContext( BlockRefs );
export function useBlockElement( clientId ) {
const [ blockElement, setBlockElement ] = useState( null );
// Delay setting the resulting `blockElement` until an effect. If the block element
// changes (i.e., the block is unmounted and re-mounted), this allows enough time
// for the ref callbacks to clean up the old element and set the new one.
useLayoutEffect( () => {
setBlockElement( refsMap.get( clientId ) );
return refsMap.subscribe( clientId, () =>
setBlockElement( refsMap.get( clientId ) )
);
}, [ refsMap, clientId ] );
useBlockElementRef( clientId, setBlockElement );
return blockElement;
}

export { useBlockRef as __unstableUseBlockRef };
export { useBlockElement as __unstableUseBlockElement };
6 changes: 5 additions & 1 deletion packages/block-editor/src/components/block-mover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ function BlockMover( {
[ clientIds ]
);

if ( ! canMove || ( isFirst && isLast && ! rootClientId ) ) {
if (
! canMove ||
( isFirst && isLast && ! rootClientId ) ||
( hideDragHandle && isManualGrid )
) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useEffect, useState, useMemo, forwardRef } from '@wordpress/element';
/**
* Internal dependencies
*/
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
import { PrivateBlockPopover } from '.';

function BlockPopoverCover(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { isRTL } from '@wordpress/i18n';
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
import usePopoverScroll from './use-popover-scroll';

const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
/**
* Internal dependencies
*/
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
import usePopoverScroll from './use-popover-scroll';

const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import BlockTitle from '../block-title';
import BlockIcon from '../block-icon';
import { store as blockEditorStore } from '../../store';
import BlockDraggable from '../block-draggable';
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
import { useBlockElement } from '../block-list/use-block-props/use-block-refs';

/**
* Block selection button component, displaying the label of the block. If the block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
import { useBlockElement } from '../block-list/use-block-props/use-block-refs';
import { hasStickyOrFixedPositionValue } from '../../hooks/position';

const COMMON_PROPS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
font-weight: 500;
line-height: 1.4;
text-transform: uppercase;
display: inline-block;
display: block;
margin-bottom: calc(4px * 2);
padding: 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default function ScaleTool( {
panelId={ panelId }
>
<ToggleGroupControl
__nextHasNoMarginBottom
label={ __( 'Scale' ) }
isBlock
help={ scaleHelp[ displayValue ] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ function BackgroundSizeControls( {
onChange={ updateBackgroundPosition }
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Fixed background' ) }
checked={ attachmentValue === 'fixed' }
onChange={ toggleScrollWithPage }
Expand All @@ -577,6 +578,7 @@ function BackgroundSizeControls( {
) }
/>
<ToggleGroupControl
__nextHasNoMarginBottom
size="__unstable-large"
label={ __( 'Size' ) }
value={ currentValueForToggle }
Expand Down Expand Up @@ -626,6 +628,7 @@ function BackgroundSizeControls( {
}
/>
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Repeat' ) }
checked={ repeatCheckedValue }
onChange={ toggleIsRepeated }
Expand Down
4 changes: 0 additions & 4 deletions packages/block-editor/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@
.block-editor-global-styles-background-panel__dropdown-content-wrapper {
min-width: 260px;
overflow-x: hidden;
.components-base-control__help,
.components-toggle-control {
margin-bottom: 0;
}

.components-focal-point-picker-wrapper {
background-color: $gray-100;
Expand Down
Loading

0 comments on commit d31e13b

Please sign in to comment.