Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/54262
Browse files Browse the repository at this point in the history
  • Loading branch information
Soean committed Nov 6, 2024
2 parents 23d3fa7 + bd11f59 commit acb9bb7
Show file tree
Hide file tree
Showing 124 changed files with 958 additions and 461 deletions.
42 changes: 22 additions & 20 deletions .github/workflows/rnmobile-android-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,28 @@ jobs:
- name: Gradle cache
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0

- name: AVD cache
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
arch: x86_64
profile: Nexus 6
script: echo "Generated AVD snapshot for caching."
# AVD cache disabled as it caused emulator termination to hang indefinitely.
# https://github.com/ReactiveCircus/android-emulator-runner/issues/385
# - name: AVD cache
# uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
# id: avd-cache
# with:
# path: |
# ~/.android/avd/*
# ~/.android/adb*
# key: avd-${{ matrix.api-level }}
#
# - name: Create AVD and generate snapshot for caching
# if: steps.avd-cache.outputs.cache-hit != 'true'
# uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0
# with:
# api-level: ${{ matrix.api-level }}
# force-avd-creation: false
# emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
# disable-animations: false
# arch: x86_64
# profile: Nexus 6
# script: echo "Generated AVD snapshot for caching."

- name: Run tests
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d # v2.33.0
Expand Down
2 changes: 1 addition & 1 deletion docs/reference-guides/data/data-core-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ Return true if the current post has already been published.
_Parameters_
- _state_ `Object`: Global application state.
- _currentPost_ `Object?`: Explicit current post for bypassing registry selector.
- _currentPost_ `[Object]`: Explicit current post for bypassing registry selector.
_Returns_
Expand Down
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.

6 changes: 3 additions & 3 deletions packages/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
"main": "build/index.js",
"module": "build-module/index.js",
"react-native": "src/index",
"types": "build-types",
"wpScript": true,
"wpScriptModuleExports": "./build-module/module/index.js",
"types": "build-types",
"dependencies": {
"@babel/runtime": "7.25.7",
"@wordpress/dom-ready": "*",
"@wordpress/i18n": "*"
},
"publishConfig": {
"access": "public"
},
"wpScript": true
}
}
4 changes: 2 additions & 2 deletions packages/annotations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"main": "build/index.js",
"module": "build-module/index.js",
"react-native": "src/index",
"wpScript": true,
"dependencies": {
"@babel/runtime": "7.25.7",
"@wordpress/data": "*",
Expand All @@ -38,6 +39,5 @@
},
"publishConfig": {
"access": "public"
},
"wpScript": true
}
}
4 changes: 2 additions & 2 deletions packages/api-fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"main": "build/index.js",
"module": "build-module/index.js",
"react-native": "src/index",
"wpScript": true,
"types": "build-types",
"dependencies": {
"@babel/runtime": "7.25.7",
Expand All @@ -34,6 +35,5 @@
},
"publishConfig": {
"access": "public"
},
"wpScript": true
}
}
4 changes: 2 additions & 2 deletions packages/autop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
"main": "build/index.js",
"module": "build-module/index.js",
"react-native": "src/index",
"wpScript": true,
"types": "build-types",
"sideEffects": false,
"dependencies": {
"@babel/runtime": "7.25.7"
},
"publishConfig": {
"access": "public"
},
"wpScript": true
}
}
4 changes: 2 additions & 2 deletions packages/blob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
"main": "build/index.js",
"module": "build-module/index.js",
"react-native": "src/index",
"wpScript": true,
"types": "build-types",
"sideEffects": false,
"dependencies": {
"@babel/runtime": "7.25.7"
},
"publishConfig": {
"access": "public"
},
"wpScript": true
}
}
4 changes: 2 additions & 2 deletions packages/block-directory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"main": "build/index.js",
"module": "build-module/index.js",
"react-native": "src/index",
"wpScript": true,
"dependencies": {
"@babel/runtime": "7.25.7",
"@wordpress/a11y": "*",
Expand Down Expand Up @@ -54,6 +55,5 @@
},
"publishConfig": {
"access": "public"
},
"wpScript": true
}
}
5 changes: 3 additions & 2 deletions packages/block-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"main": "build/index.js",
"module": "build-module/index.js",
"react-native": "src/index",
"wpScript": true,
"sideEffects": [
"build-style/**",
"src/**/*.scss",
Expand Down Expand Up @@ -59,6 +60,7 @@
"@wordpress/keycodes": "*",
"@wordpress/notices": "*",
"@wordpress/preferences": "*",
"@wordpress/priority-queue": "*",
"@wordpress/private-apis": "*",
"@wordpress/rich-text": "*",
"@wordpress/style-engine": "*",
Expand Down Expand Up @@ -87,6 +89,5 @@
},
"publishConfig": {
"access": "public"
},
"wpScript": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ iframe[name="editor-canvas"] {
width: 100%;
height: 100%;
display: block;
background-color: transparent;
// Handles transitions between device previews
@include editor-canvas-resize-animation;
background-color: $gray-300;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { BlockPatternsList } from '@wordpress/block-editor';
const MyBlockPatternsList = () => (
<BlockPatternsList
blockPatterns={ shownBlockPatterns }
shownPatterns={ shownBlockPatterns }
onClickPattern={ onSelectBlockPattern }
/>
);
Expand All @@ -33,13 +32,6 @@ An array of block patterns that can be shown in the block patterns list.
- Type: `Array`
- Required: Yes

#### shownPatterns

An array of shown block patterns objects.

- Type: `Array`
- Required: Yes

#### onClickPattern

The performed event after a click on a block pattern. In most cases, the pattern is inserted in the block editor.
Expand Down
50 changes: 23 additions & 27 deletions packages/block-editor/src/components/block-patterns-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,14 @@ function BlockPattern( {
} }
onMouseLeave={ () => onHover?.( null ) }
>
<BlockPreview
blocks={ blocks }
viewportWidth={ viewportWidth }
/>
<BlockPreview.Async
placeholder={ <BlockPatternPlaceholder /> }
>
<BlockPreview
blocks={ blocks }
viewportWidth={ viewportWidth }
/>
</BlockPreview.Async>

{ showTitle && (
<HStack
Expand Down Expand Up @@ -187,7 +191,6 @@ function BlockPatternsList(
{
isDraggable,
blockPatterns,
shownPatterns,
onHover,
onClickPattern,
orientation,
Expand All @@ -205,11 +208,9 @@ function BlockPatternsList(
// Reset the active composite item whenever the available patterns change,
// to make sure that Composite widget can receive focus correctly when its
// composite items change. The first composite item will receive focus.
const firstCompositeItemId = blockPatterns.find( ( pattern ) =>
shownPatterns.includes( pattern )
)?.name;
const firstCompositeItemId = blockPatterns[ 0 ]?.name;
setActiveCompositeId( firstCompositeItemId );
}, [ shownPatterns, blockPatterns ] );
}, [ blockPatterns ] );

return (
<Composite
Expand All @@ -221,24 +222,19 @@ function BlockPatternsList(
aria-label={ label }
ref={ ref }
>
{ blockPatterns.map( ( pattern ) => {
const isShown = shownPatterns.includes( pattern );
return isShown ? (
<BlockPattern
key={ pattern.name }
id={ pattern.name }
pattern={ pattern }
onClick={ onClickPattern }
onHover={ onHover }
isDraggable={ isDraggable }
showTitle={ showTitle }
showTooltip={ showTitlesAsTooltip }
category={ category }
/>
) : (
<BlockPatternPlaceholder key={ pattern.name } />
);
} ) }
{ blockPatterns.map( ( pattern ) => (
<BlockPattern
key={ pattern.name }
id={ pattern.name }
pattern={ pattern }
onClick={ onClickPattern }
onHover={ onHover }
isDraggable={ isDraggable }
showTitle={ showTitle }
showTooltip={ showTitlesAsTooltip }
category={ category }
/>
) ) }
{ pagingProps && <BlockPatternsPaging { ...pagingProps } /> }
</Composite>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
*/
import blockLibraryStyles from '!!raw-loader!../../../../../block-library/build-style/style.css';

/**
* WordPress dependencies
*/
import { useAsyncList } from '@wordpress/compose';

/**
* Internal dependencies
*/
Expand All @@ -26,13 +21,9 @@ export default {

export const Default = {
render: function Template( props ) {
const shownPatterns = useAsyncList( props.blockPatterns );
return (
<ExperimentalBlockEditorProvider settings={ blockEditorSettings }>
<BlockPatternsList
shownPatterns={ shownPatterns }
{ ...props }
/>
<BlockPatternsList { ...props } />
</ExperimentalBlockEditorProvider>
);
},
Expand Down
7 changes: 6 additions & 1 deletion packages/block-editor/src/components/block-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import AutoHeightBlockPreview from './auto';
import EditorStyles from '../editor-styles';
import { store as blockEditorStore } from '../../store';
import { BlockListItems } from '../block-list';
import { Async } from './async';

const EMPTY_ADDITIONAL_STYLES = [];

Expand Down Expand Up @@ -86,6 +87,10 @@ export function BlockPreview( {
);
}

const MemoizedBlockPreview = memo( BlockPreview );

MemoizedBlockPreview.Async = Async;

/**
* BlockPreview renders a preview of a block or array of blocks.
*
Expand All @@ -97,7 +102,7 @@ export function BlockPreview( {
*
* @return {Component} The component to be rendered.
*/
export default memo( BlockPreview );
export default MemoizedBlockPreview;

/**
* This hook is used to lightly mark an element as a block preview wrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import { __ } from '@wordpress/i18n';
import { cloneBlock } from '@wordpress/blocks';
import { useMemo } from '@wordpress/element';
import { useAsyncList } from '@wordpress/compose';
import { useSelect, useDispatch } from '@wordpress/data';

/**
Expand Down Expand Up @@ -81,10 +80,6 @@ export default function ChangeDesign( { clientId } ) {
.slice( 0, MAX_PATTERNS_TO_SHOW );
}, [ categories, currentPatternName, patterns ] );

const currentShownPatterns = useAsyncList(
sameCategoryPatternsWithSingleWrapper
);

if ( sameCategoryPatternsWithSingleWrapper.length < 2 ) {
return null;
}
Expand Down Expand Up @@ -121,7 +116,6 @@ export default function ChangeDesign( { clientId } ) {
paddingSize="none"
>
<BlockPatternsList
shownPatterns={ currentShownPatterns }
blockPatterns={ sameCategoryPatternsWithSingleWrapper }
onClickPattern={ onClickPattern }
showTitle={ false }
Expand Down
Loading

0 comments on commit acb9bb7

Please sign in to comment.