From a4c5f3f40150da5d0ce3ac3fb393384305ce74ad Mon Sep 17 00:00:00 2001 From: Gerardo Date: Mon, 10 Jun 2024 15:58:33 +0200 Subject: [PATCH 1/4] Native RichText - Add __unstableUseSplitSelection prop --- .../block-editor/src/components/rich-text/index.native.js | 4 ++++ 1 file changed, 4 insertions(+) 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 2697f5fdf154b..9390c71bdcf0b 100644 --- a/packages/block-editor/src/components/rich-text/index.native.js +++ b/packages/block-editor/src/components/rich-text/index.native.js @@ -80,6 +80,7 @@ export function RichTextWrapper( unstableOnFocus, __unstableAllowPrefixTransformations, // Native props. + __unstableUseSplitSelection, __unstableMobileNoFocusOnMount, deleteEnter, placeholderTextColor, @@ -178,6 +179,7 @@ export function RichTextWrapper( exitFormattedText, selectionChange, __unstableMarkAutomaticChange, + __unstableSplitSelection, clearSelectedBlock, } = useDispatch( blockEditorStore ); const adjustedAllowedFormats = getAllowedFormats( { @@ -345,6 +347,8 @@ export function RichTextWrapper( } } else if ( canSplit ) { splitValue( value ); + } else if ( __unstableUseSplitSelection ) { + __unstableSplitSelection(); } else if ( canSplitAtEnd ) { onSplitAtEnd(); } else if ( From 646b2b9c525e6ba15c7b1fcb1b51971642a420bb Mon Sep 17 00:00:00 2001 From: Gerardo Date: Mon, 10 Jun 2024 15:59:46 +0200 Subject: [PATCH 2/4] Native List block - Use __unstableUseSplitSelection prop and remove custom onSplit and onReplace functionality --- .../src/list-item/edit.native.js | 24 ++----------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/packages/block-library/src/list-item/edit.native.js b/packages/block-library/src/list-item/edit.native.js index 89f7bd0ace0b7..2367529242ded 100644 --- a/packages/block-library/src/list-item/edit.native.js +++ b/packages/block-library/src/list-item/edit.native.js @@ -21,8 +21,7 @@ import { useState, useCallback, useRef } from '@wordpress/element'; /** * Internal dependencies */ -import { useSplit, useMerge, useEnter } from './hooks'; -import { convertToListItems } from './utils'; +import { useMerge, useEnter } from './hooks'; import { IndentUI } from './edit.js'; import styles from './style.scss'; import ListStyleType from './list-style-type'; @@ -32,7 +31,6 @@ const OPACITY = '9e'; export default function ListItemEdit( { attributes, setAttributes, - onReplace, clientId, style, mergeBlocks, @@ -118,24 +116,7 @@ export default function ListItemEdit( { const preventDefault = useRef( false ); const { onEnter } = useEnter( { content, clientId }, preventDefault ); - const onSplit = useSplit( clientId ); const onMerge = useMerge( clientId, mergeBlocks ); - const onSplitList = useCallback( - ( value ) => { - if ( ! preventDefault.current ) { - return onSplit( value ); - } - }, - [ clientId, onSplit ] - ); - const onReplaceList = useCallback( - ( blocks, ...args ) => { - if ( ! preventDefault.current ) { - onReplace( convertToListItems( blocks ), ...args ); - } - }, - [ clientId, onReplace, convertToListItems ] - ); const onLayout = useCallback( ( { nativeEvent } ) => { setContentWidth( ( prevState ) => { const { width } = nativeEvent.layout; @@ -166,6 +147,7 @@ export default function ListItemEdit( { onLayout={ onLayout } > @@ -176,9 +158,7 @@ export default function ListItemEdit( { placeholderTextColor={ defaultPlaceholderTextColorWithOpacity } - onSplit={ onSplitList } onMerge={ onMerge } - onReplace={ onReplaceList } onEnter={ onEnter } style={ styleWithPlaceholderOpacity } deleteEnter From 2a6c0676dffd6fc4e25fd2d0236179e598184810 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Mon, 10 Jun 2024 18:07:25 +0200 Subject: [PATCH 3/4] Update changelog --- packages/react-native-editor/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index 44f5b63bd1f4d..1595091105b00 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -10,6 +10,7 @@ For each user feature we should also add a importance categorization label to i --> ## Unreleased +- [*] Prevent hiding the keyboard when creating new list items [#62446] ## 1.120.0 - [*] Prevent deleting content when backspacing in the first Paragraph block [#62069] From 0f25a34a6a399c0fee3741f65a205073aa46a7ba Mon Sep 17 00:00:00 2001 From: Gerardo Date: Wed, 12 Jun 2024 16:17:33 +0200 Subject: [PATCH 4/4] Fix changelog after fixing conflict --- packages/react-native-editor/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index ce42895d4f82b..1a923d19dab25 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -10,7 +10,7 @@ For each user feature we should also add a importance categorization label to i --> ## Unreleased -- [internal] Fix Inserter items list filtering [#62334]>>>>>>> trunk +- [internal] Fix Inserter items list filtering [#62334] - [*] Prevent hiding the keyboard when creating new list items [#62446] ## 1.120.0