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

[Mobile] Quote - Use nested blocks #40439

Merged
merged 2 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions packages/block-library/src/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand All @@ -254,7 +245,7 @@ export const registerCoreBlocks = ( blocksFlags ) => {
nextpage,
separator,
list,
quoteCheck( quote, blocksFlags ),
quote,
mediaText,
preformatted,
gallery,
Expand Down
4 changes: 1 addition & 3 deletions packages/edit-post/src/test/editor.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 4 additions & 7 deletions packages/react-native-editor/src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -119,12 +116,12 @@ const setupInitHooks = () => {
};

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

registerCoreBlocks( blocksFlags );
registerCoreBlocks();

blocksRegistered = true;
};
Expand Down
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
Expand Up @@ -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' );
Expand Down