diff --git a/client/post-editor/editor-title/index.jsx b/client/post-editor/editor-title/index.jsx index da0177019675e..9bf83dae29d74 100644 --- a/client/post-editor/editor-title/index.jsx +++ b/client/post-editor/editor-title/index.jsx @@ -80,7 +80,7 @@ export default React.createClass( { return; } - this.setTitle( event.target.value ); + this.setTitle( event.target.value.replace( /[\r\n]+/g, ' ' ) ); this.props.onChange( event ); }, @@ -94,37 +94,6 @@ export default React.createClass( { this.onChange( event ); }, - stripPasteNewlines( event ) { - // `window.clipboardData` deprecated as of Microsoft Edge - // See: https://msdn.microsoft.com/library/ms535220(v=vs.85).aspx - const clipboard = event.clipboardData || window.clipboardData; - if ( ! clipboard ) { - return; - } - - event.preventDefault(); - - let text = clipboard.getData( 'Text' ) || clipboard.getData( 'text/plain' ); - if ( ! text ) { - return; - } - - // Replace any newline characters with a single space - text = text.replace( /[\r\n]+/g, ' ' ); - - // Splice trimmed text into current title selection - const { value, selectionStart, selectionEnd } = event.target; - const valueChars = value.split( '' ); - valueChars.splice( selectionStart, selectionEnd - selectionStart, text ); - const newTitle = valueChars.join( '' ); - - // To preserve caret location, we track intended selection point to be - // restored after next render pass - this.selectionStart = selectionStart + text.length; - - this.setTitle( newTitle ); - }, - preventEnterKeyPress( event ) { if ( 'Enter' === event.key || 13 === event.charCode ) { event.preventDefault(); @@ -154,7 +123,6 @@ export default React.createClass( { placeholder={ this.translate( 'Title' ) } onChange={ this.onChange } onBlur={ this.onBlur } - onPaste={ this.stripPasteNewlines } onKeyPress={ this.preventEnterKeyPress } autoFocus={ isNew && ! isMobile() } value={ post ? post.title : '' }