rte: special return handling for some block types

pull/21833/head
Aviral Dasgupta 2017-03-07 04:39:38 +05:30
parent f5b52fb488
commit 79f481f81e
No known key found for this signature in database
GPG Key ID: 5FD1E9F4FFD3DA80
1 changed files with 10 additions and 3 deletions

View File

@ -513,9 +513,16 @@ export default class MessageComposerInput extends React.Component {
}; };
handleReturn = (ev) => { handleReturn = (ev) => {
if (ev.shiftKey) { const currentBlockType = RichUtils.getCurrentBlockType(this.state.editorState);
this.onEditorContentChanged(RichUtils.insertSoftNewline(this.state.editorState)); // If we're in any of these three types of blocks, shift enter should insert soft newlines
return true; // And just enter should end the block
if(['blockquote', 'unordered-list-item', 'ordered-list-item'].includes(currentBlockType)) {
if(ev.shiftKey) {
this.onEditorContentChanged(RichUtils.insertSoftNewline(this.state.editorState));
return true;
}
return false;
} }
const contentState = this.state.editorState.getCurrentContent(); const contentState = this.state.editorState.getCurrentContent();