From bf08a6132ea3c781a08079e07dec59aeaede3f37 Mon Sep 17 00:00:00 2001 From: jhnstn Date: Thu, 24 Mar 2022 12:52:18 -0400 Subject: [PATCH] Revert "[RNMobile] Pass the ol start and reversed to native RichText too (#39354)" This reverts commit 70c2b9800f2010fa011bfbafcfb357ef45ff3f70. --- .../src/components/rich-text/index.native.js | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 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 8fc0829b1b17c..f20e387819621 100644 --- a/packages/block-editor/src/components/rich-text/index.native.js +++ b/packages/block-editor/src/components/rich-text/index.native.js @@ -66,8 +66,6 @@ function RichTextWrapper( { children, tagName, - start, - reversed, value: originalValue, onChange: originalOnChange, isSelected: originalIsSelected, @@ -216,13 +214,8 @@ function RichTextWrapper( } const onSelectionChange = useCallback( - ( selectionChangeStart, selectionChangeEnd ) => { - selectionChange( - clientId, - identifier, - selectionChangeStart, - selectionChangeEnd - ); + ( start, end ) => { + selectionChange( clientId, identifier, start, end ); }, [ clientId, identifier ] ); @@ -356,11 +349,9 @@ function RichTextWrapper( onChange( insertLineSeparator( value ) ); } } else { - const { text, start: splitStart, end: splitEnd } = value; + const { text, start, end } = value; const canSplitAtEnd = - onSplitAtEnd && - splitStart === splitEnd && - splitEnd === text.length; + onSplitAtEnd && start === end && end === text.length; if ( shiftKey || ( ! canSplit && ! canSplitAtEnd ) ) { if ( ! disableLineBreaks ) { @@ -539,18 +530,15 @@ function RichTextWrapper( return; } - const { start: startPosition, text } = value; - const characterBefore = text.slice( - startPosition - 1, - startPosition - ); + const { start, text } = value; + const characterBefore = text.slice( start - 1, start ); // The character right before the caret must be a plain space. if ( characterBefore !== ' ' ) { return; } - const trimmedTextBefore = text.slice( 0, startPosition ).trim(); + const trimmedTextBefore = text.slice( 0, start ).trim(); const prefixTransforms = getBlockTransforms( 'from' ).filter( ( { type } ) => type === 'prefix' ); @@ -565,9 +553,7 @@ function RichTextWrapper( return; } - const content = valueToFormat( - slice( value, startPosition, text.length ) - ); + const content = valueToFormat( slice( value, start, text.length ) ); const block = transformation.transform( content ); onReplace( [ block ] ); @@ -589,8 +575,6 @@ function RichTextWrapper( selectionEnd={ selectionEnd } onSelectionChange={ onSelectionChange } tagName={ tagName } - start={ start } - reversed={ reversed } placeholder={ placeholder } allowedFormats={ adjustedAllowedFormats } withoutInteractiveFormatting={ withoutInteractiveFormatting }