Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add code-block to the list of blocks where hitting return will split-…
Browse files Browse the repository at this point in the history
…block

Hitting return in a code-block will now split the block into two code blocks. (Holding shift will still insert a soft newline into the current block).

We still need to make it a bit more obvious that consecutive code-blocks
are not contiguous - element-hq/element-web#4535
  • Loading branch information
Luke Barnard committed Jul 13, 2017
1 parent 33df4fa commit 219c00b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/views/rooms/MessageComposerInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,13 @@ export default class MessageComposerInput extends React.Component {
}

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
// XXX: Empirically enter does not end these blocks
if(['blockquote', 'unordered-list-item', 'ordered-list-item'].includes(currentBlockType)) {
if(
['code-block', 'blockquote', 'unordered-list-item', 'ordered-list-item']
.includes(currentBlockType)
) {
// By returning false, we allow the default draft-js key binding to occur,
// which in this case invokes "split-block". This creates a new block of the
// same type, allowing the user to delete it with backspace.
return false;
}

Expand Down

0 comments on commit 219c00b

Please sign in to comment.