Skip to content

Commit

Permalink
Fix paste in post title in GB-mobile. (#18479)
Browse files Browse the repository at this point in the history
* Fix paste on title.

* Remove html import.
  • Loading branch information
SergioEstevao committed Nov 14, 2019
1 parent 639d3c4 commit 3d1ef4b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/editor/src/components/post-title/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isEmpty } from 'lodash';
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
import { __experimentalRichText as RichText } from '@wordpress/rich-text';
import { __experimentalRichText as RichText, create, insert } from '@wordpress/rich-text';
import { decodeEntities } from '@wordpress/html-entities';
import { withDispatch, withSelect } from '@wordpress/data';
import { withFocusOutside } from '@wordpress/components';
Expand Down Expand Up @@ -43,6 +43,19 @@ class PostTitle extends Component {
this.props.onSelect();
}

onPaste( { value, onChange, plainText } ) {
const content = pasteHandler( {
plainText,
mode: 'INLINE',
tagName: 'p',
} );

if ( typeof content === 'string' ) {
const valueToInsert = create( { html: content } );
onChange( insert( value, valueToInsert ) );
}
}

render() {
const {
placeholder,
Expand Down Expand Up @@ -84,13 +97,14 @@ class PostTitle extends Component {
onChange={ ( value ) => {
this.props.onUpdate( value );
} }
onPaste={ this.onPaste }
placeholder={ decodedPlaceholder }
value={ title }
onSelectionChange={ () => { } }
onEnter={ this.props.onEnterPress }
disableEditingMenu={ true }
__unstablePasteHandler={ pasteHandler }
__unstableIsSelected={ this.props.isSelected }
__unstableOnCreateUndoLevel={ () => { } }
>
</RichText>
</View>
Expand Down

0 comments on commit 3d1ef4b

Please sign in to comment.