Skip to content

Commit

Permalink
prep build 07/07
Browse files Browse the repository at this point in the history
  • Loading branch information
bph committed Jul 7, 2023
2 parents 9404d1e + 2118e66 commit 93e24b2
Show file tree
Hide file tree
Showing 65 changed files with 1,473 additions and 760 deletions.
11 changes: 10 additions & 1 deletion lib/compat/wordpress-6.3/class-gutenberg-navigation-fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,18 @@ class Gutenberg_Navigation_Fallback {
*/
public static function get_fallback() {

/**
* Filters whether or not a fallback should be created.
*
* @since 6.3.0
*
* @param bool Whether or not to create a fallback.
*/
$should_create_fallback = apply_filters( 'gutenberg_navigation_should_create_fallback', true );

$fallback = static::get_most_recently_published_navigation();

if ( $fallback ) {
if ( $fallback || ! $should_create_fallback ) {
return $fallback;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/compat/wordpress-6.3/theme-previews.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function addLivePreviewButton() {
livePreviewButton.setAttribute('class', 'button button-primary');
livePreviewButton.setAttribute(
'href',
`/wp-admin/site-editor.php?wp_theme_preview=${themePath}&return=themes.php`
`<?php echo esc_url( admin_url( '/site-editor.php' ) ); ?>?wp_theme_preview=${themePath}&return=themes.php`
);
livePreviewButton.innerHTML = '<?php echo esc_html_e( 'Live Preview' ); ?>';
themeInfo.querySelector('.theme-actions').appendChild(livePreviewButton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,6 @@ describe( 'BlockDraggable', () => {
// "firePanGesture" finishes the dragging gesture
firePanGesture( blockDraggableWrapper );
expect( getDraggableChip( screen ) ).not.toBeDefined();

// Start dragging from block's mobile toolbar
fireLongPress(
paragraphBlock,
'draggable-trigger-mobile-toolbar'
);
expect( getDraggableChip( screen ) ).toBeVisible();
// "firePanGesture" finishes the dragging gesture
firePanGesture( blockDraggableWrapper );
expect( getDraggableChip( screen ) ).not.toBeDefined();
} ) );

it( 'does not enable drag mode when selected and editing text', async () =>
Expand Down Expand Up @@ -243,16 +233,6 @@ describe( 'BlockDraggable', () => {
// "firePanGesture" finishes the dragging gesture
firePanGesture( blockDraggableWrapper );
expect( getDraggableChip( screen ) ).not.toBeDefined();

// Start dragging from block's mobile toolbar
fireLongPress(
imageBlock,
'draggable-trigger-mobile-toolbar'
);
expect( getDraggableChip( screen ) ).toBeVisible();
// "firePanGesture" finishes the dragging gesture
firePanGesture( blockDraggableWrapper );
expect( getDraggableChip( screen ) ).not.toBeDefined();
} ) );
} );

Expand Down Expand Up @@ -301,16 +281,6 @@ describe( 'BlockDraggable', () => {
// "firePanGesture" finishes the dragging gesture
firePanGesture( blockDraggableWrapper );
expect( getDraggableChip( screen ) ).not.toBeDefined();

// Start dragging from block's mobile toolbar
fireLongPress(
galleryBlock,
'draggable-trigger-mobile-toolbar'
);
expect( getDraggableChip( screen ) ).toBeVisible();
// "firePanGesture" finishes the dragging gesture
firePanGesture( blockDraggableWrapper );
expect( getDraggableChip( screen ) ).not.toBeDefined();
} ) );

it( 'enables drag mode when nested block is selected', async () =>
Expand All @@ -336,20 +306,6 @@ describe( 'BlockDraggable', () => {
// "firePanGesture" finishes the dragging gesture
firePanGesture( blockDraggableWrapper );
expect( getDraggableChip( screen ) ).not.toBeDefined();

// After dropping the block, the gallery item gets automatically selected.
// Hence, we have to select the gallery item again.
fireEvent.press( galleryItem );

// Start dragging from nested block's mobile toolbar
fireLongPress(
galleryItem,
'draggable-trigger-mobile-toolbar'
);
expect( getDraggableChip( screen ) ).toBeVisible();
// "firePanGesture" finishes the dragging gesture
firePanGesture( blockDraggableWrapper );
expect( getDraggableChip( screen ) ).not.toBeDefined();
} ) );
} );

Expand Down Expand Up @@ -390,16 +346,6 @@ describe( 'BlockDraggable', () => {
// "firePanGesture" finishes the dragging gesture
firePanGesture( blockDraggableWrapper );
expect( getDraggableChip( screen ) ).not.toBeDefined();

// Start dragging from block's mobile toolbar
fireLongPress(
spacerBlock,
'draggable-trigger-mobile-toolbar'
);
expect( getDraggableChip( screen ) ).toBeVisible();
// "firePanGesture" finishes the dragging gesture
firePanGesture( blockDraggableWrapper );
expect( getDraggableChip( screen ) ).not.toBeDefined();
} ) );
} );
} );
Expand Down
35 changes: 26 additions & 9 deletions packages/block-editor/src/components/block-edit/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,25 @@ import BlockContext from '../block-context';
*/
const DEFAULT_BLOCK_CONTEXT = {};

export const Edit = ( props ) => {
const Edit = ( props ) => {
const { name } = props;
const blockType = getBlockType( name );

if ( ! blockType ) {
return null;
}

// `edit` and `save` are functions or components describing the markup
// with which a block is displayed. If `blockType` is valid, assign
// them preferentially as the render value for the block.
const Component = blockType.edit || blockType.save;

return <Component { ...props } />;
};

const EditWithFilters = withFilters( 'editor.BlockEdit' )( Edit );

const EditWithGeneratedProps = ( props ) => {
const { attributes = {}, name } = props;
const blockType = getBlockType( name );
const blockContext = useContext( BlockContext );
Expand All @@ -49,13 +67,8 @@ export const Edit = ( props ) => {
return null;
}

// `edit` and `save` are functions or components describing the markup
// with which a block is displayed. If `blockType` is valid, assign
// them preferentially as the render value for the block.
const Component = blockType.edit || blockType.save;

if ( blockType.apiVersion > 1 ) {
return <Component { ...props } context={ context } />;
return <EditWithFilters { ...props } context={ context } />;
}

// Generate a class name for the block's editable form.
Expand All @@ -69,8 +82,12 @@ export const Edit = ( props ) => {
);

return (
<Component { ...props } context={ context } className={ className } />
<EditWithFilters
{ ...props }
context={ context }
className={ className }
/>
);
};

export default withFilters( 'editor.BlockEdit' )( Edit );
export default EditWithGeneratedProps;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
/**
* Internal dependencies
*/
import { Edit } from '../edit';
import Edit from '../edit';
import { BlockContextProvider } from '../../block-context';

const noop = () => {};
Expand Down
30 changes: 1 addition & 29 deletions packages/block-editor/src/components/block-list/block.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import { Pressable, useWindowDimensions, View } from 'react-native';
/**
* WordPress dependencies
*/
import { useCallback, useMemo, useRef, useState } from '@wordpress/element';
import { useCallback, useMemo, useState } from '@wordpress/element';
import {
GlobalStylesContext,
getMergedGlobalStyles,
useMobileGlobalStylesColors,
alignmentHelpers,
useGlobalStyles,
} from '@wordpress/components';
import {
Expand All @@ -36,9 +35,7 @@ import { compose, ifCondition, pure } from '@wordpress/compose';
import BlockEdit from '../block-edit';
import BlockDraggable from '../block-draggable';
import BlockInvalidWarning from './block-invalid-warning';
import BlockMobileToolbar from '../block-mobile-toolbar';
import BlockOutline from './block-outline';
import styles from './block.scss';
import { store as blockEditorStore } from '../../store';
import { useLayout } from './layout';
import useSetting from '../use-setting';
Expand All @@ -63,27 +60,19 @@ function getWrapperProps( value, getWrapperPropsFunction ) {

function BlockWrapper( {
accessibilityLabel,
align,
blockWidth,
children,
clientId,
draggingClientId,
draggingEnabled,
isDescendentBlockSelected,
isParentSelected,
isSelected,
isStackedHorizontally,
isTouchable,
marginHorizontal,
marginVertical,
onDeleteBlock,
onFocus,
} ) {
const { width: screenWidth } = useWindowDimensions();
const anchorNodeRef = useRef();
const { isFullWidth } = alignmentHelpers;
const isScreenWidthEqual = blockWidth === screenWidth;
const isFullWidthToolbar = isFullWidth( align ) || isScreenWidthEqual;
const blockWrapperStyles = { flex: 1 };
const blockWrapperStyle = [
blockWrapperStyles,
Expand Down Expand Up @@ -116,19 +105,6 @@ function BlockWrapper( {
>
{ children }
</BlockDraggable>
<View style={ styles.neutralToolbar } ref={ anchorNodeRef }>
{ isSelected && (
<BlockMobileToolbar
anchorNodeRef={ anchorNodeRef.current }
blockWidth={ blockWidth }
clientId={ clientId }
draggingClientId={ draggingClientId }
isFullWidth={ isFullWidthToolbar }
isStackedHorizontally={ isStackedHorizontally }
onDelete={ onDeleteBlock }
/>
) }
</View>
</Pressable>
);
}
Expand Down Expand Up @@ -295,7 +271,6 @@ function BlockListBlock( {
),
] );

const { align } = attributes;
const isFocused = isSelected || isDescendentBlockSelected;
const isTouchable =
isSelected ||
Expand All @@ -312,8 +287,6 @@ function BlockListBlock( {
return (
<BlockWrapper
accessibilityLabel={ accessibilityLabel }
align={ align }
blockWidth={ blockWidth }
clientId={ clientId }
draggingClientId={ draggingClientId }
draggingEnabled={ draggingEnabled }
Expand All @@ -325,7 +298,6 @@ function BlockListBlock( {
isTouchable={ isTouchable }
marginHorizontal={ marginHorizontal }
marginVertical={ marginVertical }
onDeleteBlock={ onDeleteBlock }
onFocus={ onFocus }
>
{ () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,10 @@
min-height: 50px;
}

.neutralToolbar {
margin-left: -$block-edge-to-content;
margin-right: -$block-edge-to-content;
}

.solidBorder {
position: absolute;
top: -$solid-border-space;
bottom: 0;
bottom: -$solid-border-space;
left: -$solid-border-space;
right: -$solid-border-space;
border-width: $block-selected-border-width;
Expand Down
Loading

0 comments on commit 93e24b2

Please sign in to comment.