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

Backport GB 8.6 fixes to WP trunk #24068

Merged
merged 23 commits into from Jul 20, 2020
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1424ce0
Fix drag and drop for aligned blocks (#23916)
talldan Jul 14, 2020
7e47aca
Fix drag and drop to empty block lists (#23923)
talldan Jul 14, 2020
6ff8d78
Optimize selector calls (#23930)
youknowriad Jul 15, 2020
caea9f1
Update Line-Height Settings for opt-in (rather than opt-out) (#23904)
ItsJonQ Jul 15, 2020
c11ace4
Use composite pattern to improve keyboard navigation on the inserter …
youknowriad Jul 15, 2020
757ec73
persist tooltip on hover (#23959)
ntsekouras Jul 15, 2020
b170159
Make the line height and custom units theme support flags consistent …
youknowriad Jul 15, 2020
156e20a
Remove messaging that suggests contacting administrator for users wit…
StevenDufresne Jul 15, 2020
e5400d9
Remove core-embed/hulu (#23984)
tacitonic Jul 16, 2020
0777392
Fix block icon mouse out gesture issue. (#23980)
ZebulanStanphill Jul 16, 2020
5cd6da2
Fix edited Classic block's content deletion when switching to Code ed…
ntsekouras Jul 16, 2020
1e82285
Fix blocks dropping incorrectly in nested blocks (#23950)
talldan Jul 16, 2020
60ae848
Image: Add the ability for a plugin to disable Image Editor (#23966)
mkaz Jul 20, 2020
9e09f3c
Components: Fix Toolbar arrow key navigation in RTL contexts (#24043)
diegohaz Jul 20, 2020
a98ed29
RichText: restore aria-multiline (#24041)
ellatrix Jul 20, 2020
3c2507a
Fix block wrapper selector (#23991)
ellatrix Jul 20, 2020
39ebeb5
Prevent JavaScript error when using arrow navigation in URLInput (#24…
youknowriad Jul 20, 2020
66d1d2d
Editor: Fix block highlight rendering after block is moved (#23425)
ItsJonQ Jul 20, 2020
e6789f0
Fix Copy block button focus loss and try to remove the visually hidde…
afercia Jul 20, 2020
436373a
Fix Inserter on the widgets screen (#24045)
youknowriad Jul 20, 2020
83cecf0
Use CSS variable for 'ui.brand' and 'ui.borderFocus' colors (#23936)
ItsJonQ Jul 20, 2020
76f3bb2
Inserter: fix line to show again (#20792)
ellatrix Jul 20, 2020
0a9f997
Rename color value ui.brand to ui.theme. Hardcode color variable fall…
ItsJonQ Jul 20, 2020
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -670,7 +670,7 @@ function gutenberg_extend_settings_block_patterns( $settings ) {
* @return array Filtered editor settings.
*/
function gutenberg_extend_settings_custom_line_height( $settings ) {
$settings['__experimentalDisableCustomLineHeight'] = get_theme_support( 'disable-custom-line-height' );
$settings['enableCustomLineHeight'] = get_theme_support( 'custom-line-height' );
return $settings;
}
add_filter( 'block_editor_settings', 'gutenberg_extend_settings_custom_line_height' );
@@ -684,7 +684,7 @@ function gutenberg_extend_settings_custom_line_height( $settings ) {
* @return array Filtered editor settings.
*/
function gutenberg_extend_settings_custom_units( $settings ) {
$settings['__experimentalDisableCustomUnits'] = get_theme_support( 'experimental-custom-units' );
$settings['enableCustomUnits'] = get_theme_support( 'custom-units' );
return $settings;
}
add_filter( 'block_editor_settings', 'gutenberg_extend_settings_custom_units' );

Some generated files are not rendered by default. Learn more.

@@ -22,18 +22,10 @@ function DownloadableBlocksPanel( {
debouncedSpeak,
} ) {
if ( false === hasPermission ) {
debouncedSpeak(
__(
'No blocks found in your library. Please contact your site administrator to install new blocks.'
)
);
debouncedSpeak( __( 'No blocks found in your library.' ) );
return (
<p className="block-directory-downloadable-blocks-panel__description has-no-results">
{ __( 'No blocks found in your library.' ) }
<br />
{ __(
'Please contact your site administrator to install new blocks.'
) }
</p>
);
}
@@ -481,6 +481,7 @@ _Properties_
- _disableCustomColors_ `boolean`: Whether or not the custom colors are disabled
- _fontSizes_ `Array`: Available font sizes
- _disableCustomFontSizes_ `boolean`: Whether or not the custom font sizes are disabled
- _imageEditing_ `boolean`: Image Editing settings set to false to disable.
- _imageSizes_ `Array`: Available image sizes
- _maxWidth_ `number`: Max width to constraint resizing
- _allowedBlockTypes_ `(boolean|Array)`: Allowed block types
@@ -60,6 +60,7 @@
"memize": "^1.1.0",
"react-autosize-textarea": "^3.0.2",
"react-spring": "^8.0.19",
"reakit": "1.1.0",
"redux-multi": "^0.1.12",
"refx": "^3.0.0",
"rememo": "^3.0.0",
@@ -71,6 +71,7 @@ const BlockComponent = forwardRef(
initialPosition: isSelected
? getSelectedBlocksInitialCaretPosition()
: undefined,
isNavigationMode: _isNavigationMode,
};
},
[ isSelected ]
@@ -6,7 +6,12 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { useState, createContext, useMemo } from '@wordpress/element';
import {
useState,
createContext,
useMemo,
useCallback,
} from '@wordpress/element';
import {
getBlockType,
getSaveElement,
@@ -105,7 +110,7 @@ function BlockListBlock( {
[ clientId ]
);
const { removeBlock } = useDispatch( 'core/block-editor' );
const onRemove = () => removeBlock( clientId );
const onRemove = useCallback( () => removeBlock( clientId ), [ clientId ] );

// Handling the error state
const [ hasError, setErrorState ] = useState( false );
@@ -18,57 +18,139 @@ import Inserter from '../inserter';
import { getClosestTabbable } from '../writing-flow';
import { getBlockDOMNode } from '../../utils/dom';

function Indicator( { clientId } ) {
const showInsertionPoint = useSelect(
function InsertionPointInserter( {
clientId,
setIsInserterForced,
containerRef,
} ) {
const ref = useRef();
// Hide the inserter above the selected block and during multi-selection.
const isInserterHidden = useSelect(
( select ) => {
const {
getBlockIndex,
getBlockInsertionPoint,
isBlockInsertionPointVisible,
getBlockRootClientId,
getMultiSelectedBlockClientIds,
getSelectedBlockClientId,
hasMultiSelection,
} = select( 'core/block-editor' );
const rootClientId = getBlockRootClientId( clientId );
const blockIndex = getBlockIndex( clientId, rootClientId );
const insertionPoint = getBlockInsertionPoint();
return (
isBlockInsertionPointVisible() &&
insertionPoint.index === blockIndex &&
insertionPoint.rootClientId === rootClientId
);
const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds();
const selectedBlockClientId = getSelectedBlockClientId();

return hasMultiSelection()
? multiSelectedBlockClientIds.includes( clientId )
: clientId === selectedBlockClientId;
},
[ clientId ]
);

if ( ! showInsertionPoint ) {
return null;
function focusClosestTabbable( event ) {
const { clientX, clientY, target } = event;

// Only handle click on the wrapper specifically, and not an event
// bubbled from the inserter itself.
if ( target !== ref.current ) {
return;
}

const targetRect = target.getBoundingClientRect();
const isReverse = clientY < targetRect.top + targetRect.height / 2;
const blockNode = getBlockDOMNode( clientId );
const container = isReverse ? containerRef.current : blockNode;
const closest =
getClosestTabbable( blockNode, true, container ) || blockNode;
const rect = new window.DOMRect( clientX, clientY, 0, 16 );

placeCaretAtVerticalEdge( closest, isReverse, rect, false );
}

return (
<div className="block-editor-block-list__insertion-point-indicator" />
/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
<div
ref={ ref }
onFocus={ () => setIsInserterForced( true ) }
onBlur={ () => setIsInserterForced( false ) }
onClick={ focusClosestTabbable }
// While ideally it would be enough to capture the
// bubbling focus event from the Inserter, due to the
// characteristics of click focusing of `button`s in
// Firefox and Safari, it is not reliable.
//
// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
tabIndex={ -1 }
className={ classnames(
'block-editor-block-list__insertion-point-inserter',
{
'is-inserter-hidden': isInserterHidden,
}
) }
>
<Inserter
position="bottom center"
clientId={ clientId }
__experimentalIsQuick
/>
</div>
);
}

export default function InsertionPoint( {
hasMultiSelection,
selectedBlockClientId,
children,
function InsertionPointPopover( {
clientId,
isInserterShown,
isInserterForced,
setIsInserterForced,
containerRef,
showInsertionPoint,
} ) {
const element = getBlockDOMNode( clientId );

return (
<Popover
noArrow
animate={ false }
anchorRef={ element }
position="top right left"
focusOnMount={ false }
className="block-editor-block-list__insertion-point-popover"
__unstableSlotName="block-toolbar"
>
<div
className="block-editor-block-list__insertion-point"
style={ { width: element?.offsetWidth } }
>
{ showInsertionPoint && (
<div className="block-editor-block-list__insertion-point-indicator" />
) }
{ ( isInserterShown || isInserterForced ) && (
<InsertionPointInserter
clientId={ clientId }
setIsInserterForced={ setIsInserterForced }
containerRef={ containerRef }
/>
) }
</div>
</Popover>
);
}

export default function InsertionPoint( { children, containerRef } ) {
const [ isInserterShown, setIsInserterShown ] = useState( false );
const [ isInserterForced, setIsInserterForced ] = useState( false );
const [ inserterElement, setInserterElement ] = useState( null );
const [ inserterClientId, setInserterClientId ] = useState( null );
const ref = useRef();
const { multiSelectedBlockClientIds, isMultiSelecting } = useSelect(
const { isMultiSelecting, isInserterVisible, selectedClientId } = useSelect(
( select ) => {
const {
getMultiSelectedBlockClientIds,
isMultiSelecting: _isMultiSelecting,
isBlockInsertionPointVisible,
getBlockInsertionPoint,
getBlockOrder,
} = select( 'core/block-editor' );

const insertionPoint = getBlockInsertionPoint();
const order = getBlockOrder( insertionPoint.rootClientId );

return {
isMultiSelecting: _isMultiSelecting(),
multiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),
isInserterVisible: isBlockInsertionPointVisible(),
selectedClientId: order[ insertionPoint.index ],
};
},
[]
@@ -117,80 +199,24 @@ export default function InsertionPoint( {
}

setIsInserterShown( true );
setInserterElement( element );
setInserterClientId( clientId );
}

function focusClosestTabbable( event ) {
const { clientX, clientY, target } = event;

// Only handle click on the wrapper specifically, and not an event
// bubbled from the inserter itself.
if ( target !== ref.current ) {
return;
}

const targetRect = target.getBoundingClientRect();
const isReverse = clientY < targetRect.top + targetRect.height / 2;
const blockNode = getBlockDOMNode( inserterClientId );
const container = isReverse ? containerRef.current : blockNode;
const closest =
getClosestTabbable( blockNode, true, container ) || blockNode;
const rect = new window.DOMRect( clientX, clientY, 0, 16 );

placeCaretAtVerticalEdge( closest, isReverse, rect, false );
}

// Hide the inserter above the selected block and during multi-selection.
const isInserterHidden = hasMultiSelection
? multiSelectedBlockClientIds.includes( inserterClientId )
: inserterClientId === selectedBlockClientId;
const isVisible = isInserterShown || isInserterForced || isInserterVisible;

return (
<>
{ ! isMultiSelecting && ( isInserterShown || isInserterForced ) && (
<Popover
noArrow
animate={ false }
anchorRef={ inserterElement }
position="top right left"
focusOnMount={ false }
className="block-editor-block-list__insertion-point-popover"
__unstableSlotName="block-toolbar"
>
<div
className="block-editor-block-list__insertion-point"
style={ { width: inserterElement.offsetWidth } }
>
<Indicator clientId={ inserterClientId } />
{ /* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */ }
<div
ref={ ref }
onFocus={ () => setIsInserterForced( true ) }
onBlur={ () => setIsInserterForced( false ) }
onClick={ focusClosestTabbable }
// While ideally it would be enough to capture the
// bubbling focus event from the Inserter, due to the
// characteristics of click focusing of `button`s in
// Firefox and Safari, it is not reliable.
//
// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
tabIndex={ -1 }
className={ classnames(
'block-editor-block-list__insertion-point-inserter',
{
'is-inserter-hidden': isInserterHidden,
}
) }
>
<Inserter
position="bottom center"
clientId={ inserterClientId }
__experimentalIsQuick
/>
</div>
</div>
</Popover>
{ ! isMultiSelecting && isVisible && (
<InsertionPointPopover
clientId={
isInserterVisible ? selectedClientId : inserterClientId
}
isInserterShown={ isInserterShown }
isInserterForced={ isInserterForced }
setIsInserterForced={ setIsInserterForced }
containerRef={ containerRef }
showInsertionPoint={ isInserterVisible }
/>
) }
<div
onMouseMove={
@@ -79,11 +79,7 @@ function RootContainer( { children, className }, ref ) {
const [ blockNodes, setBlockNodes ] = useState( {} );

return (
<InsertionPoint
hasMultiSelection={ hasMultiSelection }
selectedBlockClientId={ selectedBlockClientId }
containerRef={ ref }
>
<InsertionPoint containerRef={ ref }>
<BlockNodes.Provider value={ blockNodes }>
<BlockPopover />
<div
@@ -391,7 +391,7 @@

// Hide the inserter above the selected block.
&.is-inserter-hidden .block-editor-inserter__toggle {
opacity: 0;
visibility: hidden;
pointer-events: none;
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.