diff --git a/packages/block-editor/src/components/block-settings/container.native.js b/packages/block-editor/src/components/block-settings/container.native.js
index a91fc582d589d..c324d0afbe86d 100644
--- a/packages/block-editor/src/components/block-settings/container.native.js
+++ b/packages/block-editor/src/components/block-settings/container.native.js
@@ -2,7 +2,11 @@
* WordPress dependencies
*/
import { InspectorControls } from '@wordpress/block-editor';
-import { BottomSheet, ColorSettings } from '@wordpress/components';
+import {
+ BottomSheet,
+ ColorSettings,
+ LinkPickerScreen,
+} from '@wordpress/components';
import { compose } from '@wordpress/compose';
import { withDispatch, withSelect } from '@wordpress/data';
/**
@@ -13,6 +17,7 @@ import styles from './container.native.scss';
export const blockSettingsScreens = {
settings: 'Settings',
color: 'Color',
+ linkPicker: 'linkPicker',
};
function BottomSheetSettings( {
@@ -41,6 +46,15 @@ function BottomSheetSettings( {
>
+
+
+
);
diff --git a/packages/block-library/src/button/edit.native.js b/packages/block-library/src/button/edit.native.js
index 508a36a813057..d437a8b12d28b 100644
--- a/packages/block-library/src/button/edit.native.js
+++ b/packages/block-library/src/button/edit.native.js
@@ -19,7 +19,7 @@ import {
RangeControl,
ToolbarGroup,
ToolbarButton,
- LinkSettings,
+ LinkSettingsNavigation,
} from '@wordpress/components';
import { Component } from '@wordpress/element';
import { withSelect, withDispatch } from '@wordpress/data';
@@ -242,7 +242,7 @@ class ButtonEdit extends Component {
};
return (
-
) }
- {
+ const navigation = useNavigation();
+ const route = useRoute();
+
+ const onLinkPicked = ( { url, title } ) => {
+ navigation.navigate( returnScreenName, {
+ inputValue: url,
+ text: title,
+ } );
+ };
+
+ const onCancel = () => {
+ navigation.goBack();
+ };
+
+ const { inputValue } = route.params;
+ return useMemo( () => {
+ return (
+
+ );
+ }, [ inputValue ] );
+};
+
+export default LinkPickerScreen;
diff --git a/packages/components/src/mobile/link-settings/index.native.js b/packages/components/src/mobile/link-settings/index.native.js
index b809080b4a29f..e10db29379399 100644
--- a/packages/components/src/mobile/link-settings/index.native.js
+++ b/packages/components/src/mobile/link-settings/index.native.js
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
-import { Platform, Clipboard } from 'react-native';
+import { Clipboard } from 'react-native';
/**
* WordPress dependencies
*/
@@ -9,7 +9,7 @@ import { compose } from '@wordpress/compose';
import { withSelect } from '@wordpress/data';
import { isURL, prependHTTP } from '@wordpress/url';
import { useEffect, useState, useRef } from '@wordpress/element';
-import { link, external } from '@wordpress/icons';
+import { external } from '@wordpress/icons';
/**
* Internal dependencies
@@ -80,6 +80,8 @@ function LinkSettings( {
editorSidebarOpened,
// Specifies whether icon should be displayed next to the label
showIcon,
+ onLinkCellPressed,
+ urlValue,
} ) {
const { url, label, linkTarget, rel } = attributes;
const [ urlInputValue, setUrlInputValue ] = useState( '' );
@@ -115,12 +117,14 @@ function LinkSettings( {
}
}, [ editorSidebarOpened, isVisible ] );
- function onChangeURL( value ) {
- if ( ! value && onEmptyURL ) {
+ useEffect( () => {
+ if ( ! urlValue && onEmptyURL ) {
onEmptyURL();
}
- setUrlInputValue( value );
- }
+ setAttributes( {
+ url: prependHTTP( urlValue ),
+ } );
+ }, [ urlValue ] );
function onChangeLabel( value ) {
setLabelInputValue( value );
@@ -177,20 +181,10 @@ function LinkSettings( {
return (
<>
{ options.url && (
-
) }
{ options.linkLabel && (
@@ -231,11 +225,7 @@ function LinkSettings( {
}
return (
-
+ <>
{ getSettings() }
@@ -248,7 +238,7 @@ function LinkSettings( {
) }
{ actions && }
-
+ >
);
}
diff --git a/packages/components/src/mobile/link-settings/link-settings-navigation.native.js b/packages/components/src/mobile/link-settings/link-settings-navigation.native.js
new file mode 100644
index 0000000000000..a71b53bf9a2fa
--- /dev/null
+++ b/packages/components/src/mobile/link-settings/link-settings-navigation.native.js
@@ -0,0 +1,44 @@
+/**
+ * Internal dependencies
+ */
+import BottomSheet from '../bottom-sheet';
+import LinkSettingsScreen from './link-settings-screen';
+import LinkPickerScreen from '../link-picker/link-picker-screen';
+
+const linkSettingsScreens = {
+ settings: 'LinkSettingsScreen',
+ linkPicker: 'linkPicker',
+};
+
+function LinkSettingsNavigation( props ) {
+ if ( ! props.withBottomSheet ) {
+ return ;
+ }
+ return (
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default LinkSettingsNavigation;
diff --git a/packages/components/src/mobile/link-settings/link-settings-screen.native.js b/packages/components/src/mobile/link-settings/link-settings-screen.native.js
new file mode 100644
index 0000000000000..49f240c2074d0
--- /dev/null
+++ b/packages/components/src/mobile/link-settings/link-settings-screen.native.js
@@ -0,0 +1,36 @@
+/**
+ * External dependencies
+ */
+import React from 'react';
+import { useNavigation, useRoute } from '@react-navigation/native';
+/**
+ * WordPress dependencies
+ */
+import { useMemo } from '@wordpress/element';
+/**
+ * Internal dependencies
+ */
+import LinkSettings from './';
+
+const LinkSettingsScreen = ( props ) => {
+ const navigation = useNavigation();
+ const route = useRoute();
+ const { url = '' } = props.attributes || {};
+ const { inputValue = url } = route.params || {};
+
+ const onLinkCellPressed = () => {
+ navigation.navigate( 'linkPicker', { inputValue } );
+ };
+
+ return useMemo( () => {
+ return (
+
+ );
+ }, [ props, inputValue, navigation, route ] );
+};
+
+export default LinkSettingsScreen;