Skip to content

Commit

Permalink
Add preserve white space to the native version. (#18809)
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioEstevao authored Nov 29, 2019
1 parent be34e5b commit d385ec1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/rich-text/src/component/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ export class RichText extends Component {
* @return {Object} A RichText value with formats and selection.
*/
createRecord() {
const {
preserveWhiteSpace,
} = this.props;
const value = {
start: this.selectionStart,
end: this.selectionEnd,
Expand All @@ -137,6 +140,7 @@ export class RichText extends Component {
range: null,
multilineTag: this.multilineTag,
multilineWrapperTags: this.multilineWrapperTags,
preserveWhiteSpace,
} ),
};
const start = Math.min( this.selectionStart, value.text.length );
Expand Down Expand Up @@ -464,12 +468,16 @@ export class RichText extends Component {
}

formatToValue( value ) {
const {
preserveWhiteSpace,
} = this.props;
// Handle deprecated `children` and `node` sources.
if ( Array.isArray( value ) ) {
return create( {
html: childrenBlock.toHTML( value ),
multilineTag: this.multilineTag,
multilineWrapperTags: this.multilineWrapperTags,
preserveWhiteSpace,
} );
}

Expand All @@ -478,6 +486,7 @@ export class RichText extends Component {
html: value,
multilineTag: this.multilineTag,
multilineWrapperTags: this.multilineWrapperTags,
preserveWhiteSpace,
} );
}

Expand Down

0 comments on commit d385ec1

Please sign in to comment.