Skip to content

Commit

Permalink
Revert "[RNMobile] Pass the ol start and reversed to native RichText …
Browse files Browse the repository at this point in the history
…too (#39354)"

This reverts commit 70c2b98.
  • Loading branch information
jhnstn committed Mar 24, 2022
1 parent b2234d6 commit bf08a61
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions packages/block-editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ function RichTextWrapper(
{
children,
tagName,
start,
reversed,
value: originalValue,
onChange: originalOnChange,
isSelected: originalIsSelected,
Expand Down Expand Up @@ -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 ]
);
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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'
);
Expand All @@ -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 ] );
Expand All @@ -589,8 +575,6 @@ function RichTextWrapper(
selectionEnd={ selectionEnd }
onSelectionChange={ onSelectionChange }
tagName={ tagName }
start={ start }
reversed={ reversed }
placeholder={ placeholder }
allowedFormats={ adjustedAllowedFormats }
withoutInteractiveFormatting={ withoutInteractiveFormatting }
Expand Down

0 comments on commit bf08a61

Please sign in to comment.