allow user to break out of blockquote/etc by hitting enter twice
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
5b79e3bcd5
commit
ff76b6a981
1 changed files with 19 additions and 5 deletions
|
@ -990,15 +990,29 @@ export default class MessageComposerInput extends React.Component {
|
||||||
return change.insertText('\n');
|
return change.insertText('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.editorState.blocks.some(
|
const editorState = this.state.editorState;
|
||||||
block => ['code', 'block-quote', 'list-item'].includes(block.type)
|
|
||||||
)) {
|
let inBlock = false;
|
||||||
|
let inEmptyBlock = false;
|
||||||
|
|
||||||
|
for (const block of editorState.blocks) {
|
||||||
|
if (['code', 'block-quote', 'list-item'].includes(block.type)) {
|
||||||
|
inBlock = true;
|
||||||
|
if (block.text === '') {
|
||||||
|
inEmptyBlock = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inEmptyBlock) {
|
||||||
|
// allow the user to cancel empty block by hitting return, useful in conjunction with below `inBlock`
|
||||||
|
return change.setBlocks(DEFAULT_NODE);
|
||||||
|
} else if (inBlock) {
|
||||||
// allow the user to terminate blocks by hitting return rather than sending a msg
|
// allow the user to terminate blocks by hitting return rather than sending a msg
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const editorState = this.state.editorState;
|
|
||||||
|
|
||||||
let contentText;
|
let contentText;
|
||||||
let contentHTML;
|
let contentHTML;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue