Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Mobile] Quote - Use nested blocks (#40439)
Browse files Browse the repository at this point in the history
* Mobile - Remove Quote V2 check on registration

* Mobile - Tests - initializes the editor: With inner blocks we need to get the first element which is the main list
Gerardo Pacheco authored and oandregal committed Apr 29, 2022
1 parent 93d5890 commit 13cd301
Showing 4 changed files with 9 additions and 22 deletions.
13 changes: 2 additions & 11 deletions packages/block-library/src/index.native.js
Original file line number Diff line number Diff line change
@@ -179,14 +179,6 @@ const devOnly = ( block ) => ( !! __DEV__ ? block : null );
const iOSOnly = ( block ) =>
Platform.OS === 'ios' ? block : devOnly( block );

// To be removed once Quote V2 is released on the web editor.
function quoteCheck( quoteBlock, blocksFlags ) {
if ( blocksFlags?.__experimentalEnableQuoteBlockV2 ) {
quoteBlock.settings = quoteBlock?.settingsV2;
}
return quoteBlock;
}

// Hide the Classic block and SocialLink block
addFilter(
'blocks.registerBlockType',
@@ -238,10 +230,9 @@ addFilter(
*
* registerCoreBlocks();
* ```
* @param {Object} [blocksFlags] Experimental flags
*
*/
export const registerCoreBlocks = ( blocksFlags ) => {
export const registerCoreBlocks = () => {
// When adding new blocks to this list please also consider updating /src/block-support/supported-blocks.json in the Gutenberg-Mobile repo
[
paragraph,
@@ -254,7 +245,7 @@ export const registerCoreBlocks = ( blocksFlags ) => {
nextpage,
separator,
list,
quoteCheck( quote, blocksFlags ),
quote,
mediaText,
preformatted,
gallery,
4 changes: 1 addition & 3 deletions packages/edit-post/src/test/editor.native.js
Original file line number Diff line number Diff line change
@@ -28,9 +28,7 @@ const unsupportedBlock = `
jest.useFakeTimers( 'legacy' );

describe( 'Editor', () => {
beforeAll( () => {
registerCoreBlocks();
} );
beforeAll( registerCoreBlocks );

it( 'detects unsupported block and sends hasUnsupportedBlocks true to native', () => {
RNReactNativeGutenbergBridge.editorDidMount = jest.fn();
11 changes: 4 additions & 7 deletions packages/react-native-editor/src/setup.js
Original file line number Diff line number Diff line change
@@ -58,12 +58,9 @@ const gutenbergSetup = () => {

const setupInitHooks = () => {
addAction( 'native.pre-render', 'core/react-native-editor', ( props ) => {
const capabilities = props.capabilities ?? {};
const blocksFlags = {
__experimentalEnableQuoteBlockV2: props?.quoteBlockV2,
};
registerBlocks();

registerBlocks( blocksFlags );
const capabilities = props.capabilities ?? {};

// Unregister non-supported blocks by capabilities
if (
@@ -119,12 +116,12 @@ const setupInitHooks = () => {
};

let blocksRegistered = false;
const registerBlocks = ( blocksFlags ) => {
const registerBlocks = () => {
if ( blocksRegistered ) {
return;
}

registerCoreBlocks( blocksFlags );
registerCoreBlocks();

blocksRegistered = true;
};
3 changes: 2 additions & 1 deletion packages/react-native-editor/src/test/index.test.js
Original file line number Diff line number Diff line change
@@ -190,7 +190,8 @@ describe( 'Register Gutenberg', () => {
{},
{ component: EditorComponent }
);
const blockList = screen.getByTestId( 'block-list-wrapper' );
// Inner blocks create BlockLists so let's take into account selecting the main one
const blockList = screen.getAllByTestId( 'block-list-wrapper' )[ 0 ];

expect( blockList ).toBeVisible();
expect( console ).toHaveLoggedWith( 'Hermes is: true' );

0 comments on commit 13cd301

Please sign in to comment.