Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactNative - Block splitting - Handle the case when the split occurs at the trailing or leading edge #10737

Merged
merged 1 commit into from
Oct 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions packages/editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Component, RawHTML } from '@wordpress/element';
import { withInstanceId, compose } from '@wordpress/compose';
import { Toolbar } from '@wordpress/components';
import {
isEmpty,
create,
split,
toHTMLString,
Expand Down Expand Up @@ -87,10 +88,18 @@ export class RichText extends Component {
} );

// TODO : Fix the index position in AztecNative for Android
let [ before, after ] = split( { start: start - 6, end: end - 6, ...record } );

// TODO : Handle here the cases when the split happens at the trailing or leading edge...
// See the web version for reference.
let [ before, after ] = split( { start, end, ...record } );

// In case split occurs at the trailing or leading edge of the field,
// assume that the before/after values respectively reflect the current
// value. This also provides an opportunity for the parent component to
// determine whether the before/after value has changed using a trivial
// strict equality operation.
if ( isEmpty( after ) ) {
before = record;
} else if ( isEmpty( before ) ) {
after = record;
}

if ( before ) {
before = this.valueToFormat( before );
Expand Down