From 6d54b9885a3d94c4f659c849750b9babda618acc Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 28 Mar 2024 12:05:27 -0500 Subject: [PATCH 1/2] test: Define missing `logException` native module mock Prevent cryptic test failure messages originating from invoking this undefined method, which prevented the original error message from surfacing in the test failure log. --- test/native/setup.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/native/setup.js b/test/native/setup.js index 54a416bd43660..4fd511f38e91b 100644 --- a/test/native/setup.js +++ b/test/native/setup.js @@ -81,6 +81,7 @@ jest.mock( '@wordpress/api-fetch', () => { jest.mock( '@wordpress/react-native-bridge', () => { return { addEventListener: jest.fn(), + logException: jest.fn(), mediaUploadSync: jest.fn(), removeEventListener: jest.fn(), requestBlockTypeImpressions: jest.fn( ( callback ) => { From aa7bf72d74028b322a94a1e8d7018128b04d92f7 Mon Sep 17 00:00:00 2001 From: David Calhoun Date: Thu, 28 Mar 2024 12:21:37 -0500 Subject: [PATCH 2/2] refactor: Export private API Rich Text module This export was added for interoperability with the web version modified in https://github.com/WordPress/gutenberg/pull/58916. --- .../src/components/rich-text/index.native.js | 15 +++++++++------ packages/block-editor/src/private-apis.native.js | 2 ++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/components/rich-text/index.native.js b/packages/block-editor/src/components/rich-text/index.native.js index 41e5a7635d2f0..1be6551302edf 100644 --- a/packages/block-editor/src/components/rich-text/index.native.js +++ b/packages/block-editor/src/components/rich-text/index.native.js @@ -655,29 +655,32 @@ export function RichTextWrapper( ); } -const ForwardedRichTextContainer = withDeprecations( +// This export does not actually implement a private API, but was exported +// under this name for interoperability with the web version of the RichText +// component. +export const PrivateRichText = withDeprecations( forwardRef( RichTextWrapper ) ); -ForwardedRichTextContainer.Content = Content; +PrivateRichText.Content = Content; -ForwardedRichTextContainer.isEmpty = ( value ) => { +PrivateRichText.isEmpty = ( value ) => { return ! value || value.length === 0; }; -ForwardedRichTextContainer.Content.defaultProps = { +PrivateRichText.Content.defaultProps = { format: 'string', value: '', }; -ForwardedRichTextContainer.Raw = forwardRef( ( props, ref ) => ( +PrivateRichText.Raw = forwardRef( ( props, ref ) => ( ) ); /** * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md */ -export default ForwardedRichTextContainer; +export default PrivateRichText; export { RichTextShortcut } from './shortcut'; export { RichTextToolbarButton } from './toolbar-button'; export { __unstableRichTextInputEvent } from './input-event'; diff --git a/packages/block-editor/src/private-apis.native.js b/packages/block-editor/src/private-apis.native.js index 7a0328eba2f6f..f99d523933106 100644 --- a/packages/block-editor/src/private-apis.native.js +++ b/packages/block-editor/src/private-apis.native.js @@ -5,6 +5,7 @@ import * as globalStyles from './components/global-styles'; import { ExperimentalBlockEditorProvider } from './components/provider'; import { getRichTextValues } from './components/rich-text/get-rich-text-values'; import { lock } from './lock-unlock'; +import { PrivateRichText } from './components/rich-text/'; /** * Private @wordpress/block-editor APIs. @@ -14,4 +15,5 @@ lock( privateApis, { ...globalStyles, ExperimentalBlockEditorProvider, getRichTextValues, + PrivateRichText, } );