From 35acb435573f59bcfc8f25841040b81df4eb525d Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Wed, 13 Nov 2019 14:23:46 +0000 Subject: [PATCH 1/2] Fix paste on title. --- .../src/components/post-title/index.native.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/components/post-title/index.native.js b/packages/editor/src/components/post-title/index.native.js index a47de19cfaa1c..ae5f5965666c7 100644 --- a/packages/editor/src/components/post-title/index.native.js +++ b/packages/editor/src/components/post-title/index.native.js @@ -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'; @@ -43,6 +43,20 @@ class PostTitle extends Component { this.props.onSelect(); } + onPaste( { value, onChange, html, plainText } ) { + const content = pasteHandler( { + HTML: html, + plainText, + mode: 'INLINE', + tagName: 'p', + } ); + + if ( typeof content === 'string' ) { + const valueToInsert = create( { html: content } ); + onChange( insert( value, valueToInsert ) ); + } + } + render() { const { placeholder, @@ -84,13 +98,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={ () => { } } > From f11bc3f803bc76fdf48b05ecd427b4b1919ede18 Mon Sep 17 00:00:00 2001 From: Sergio Estevao Date: Thu, 14 Nov 2019 09:46:18 +0000 Subject: [PATCH 2/2] Remove html import. --- packages/editor/src/components/post-title/index.native.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/editor/src/components/post-title/index.native.js b/packages/editor/src/components/post-title/index.native.js index ae5f5965666c7..13bee48224509 100644 --- a/packages/editor/src/components/post-title/index.native.js +++ b/packages/editor/src/components/post-title/index.native.js @@ -43,9 +43,8 @@ class PostTitle extends Component { this.props.onSelect(); } - onPaste( { value, onChange, html, plainText } ) { + onPaste( { value, onChange, plainText } ) { const content = pasteHandler( { - HTML: html, plainText, mode: 'INLINE', tagName: 'p',