mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-14 07:50:33 +03:00
rte: special return handling for some block types
This commit is contained in:
parent
f5b52fb488
commit
79f481f81e
1 changed files with 10 additions and 3 deletions
|
@ -513,11 +513,18 @@ export default class MessageComposerInput extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
handleReturn = (ev) => {
|
handleReturn = (ev) => {
|
||||||
|
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) {
|
if(ev.shiftKey) {
|
||||||
this.onEditorContentChanged(RichUtils.insertSoftNewline(this.state.editorState));
|
this.onEditorContentChanged(RichUtils.insertSoftNewline(this.state.editorState));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const contentState = this.state.editorState.getCurrentContent();
|
const contentState = this.state.editorState.getCurrentContent();
|
||||||
if (!contentState.hasText()) {
|
if (!contentState.hasText()) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue