1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-30 02:21:17 +03:00

rte: special return handling for some block types

This commit is contained in:
Aviral Dasgupta
2017-03-07 04:39:38 +05:30
parent f5b52fb488
commit 79f481f81e

View File

@ -513,9 +513,16 @@ export default class MessageComposerInput extends React.Component {
};
handleReturn = (ev) => {
if (ev.shiftKey) {
this.onEditorContentChanged(RichUtils.insertSoftNewline(this.state.editorState));
return true;
const currentBlockType = RichUtils.getCurrentBlockType(this.state.editorState);
// If we're in any of these three types of blocks, shift enter should insert soft newlines
// 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();