mirror of https://github.com/vector-im/riot-web
Merge pull request #1174 from matrix-org/luke/fix-rte-edge-detection
Only move through history if caret at start or end of linepull/21833/head
commit
d130411f6b
|
@ -640,17 +640,16 @@ export default class MessageComposerInput extends React.Component {
|
||||||
const firstBlock = this.state.editorState.getCurrentContent().getFirstBlock();
|
const firstBlock = this.state.editorState.getCurrentContent().getFirstBlock();
|
||||||
const lastBlock = this.state.editorState.getCurrentContent().getLastBlock();
|
const lastBlock = this.state.editorState.getCurrentContent().getLastBlock();
|
||||||
|
|
||||||
const selectionOffset = selection.getAnchorOffset();
|
|
||||||
let canMoveUp = false;
|
let canMoveUp = false;
|
||||||
let canMoveDown = false;
|
let canMoveDown = false;
|
||||||
if (blockKey === firstBlock.getKey()) {
|
if (blockKey === firstBlock.getKey()) {
|
||||||
const textBeforeCursor = firstBlock.getText().slice(0, selectionOffset);
|
canMoveUp = selection.getStartOffset() === selection.getEndOffset() &&
|
||||||
canMoveUp = textBeforeCursor.indexOf('\n') === -1;
|
selection.getStartOffset() === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockKey === lastBlock.getKey()) {
|
if (blockKey === lastBlock.getKey()) {
|
||||||
const textAfterCursor = lastBlock.getText().slice(selectionOffset);
|
canMoveDown = selection.getStartOffset() === selection.getEndOffset() &&
|
||||||
canMoveDown = textAfterCursor.indexOf('\n') === -1;
|
selection.getStartOffset() === lastBlock.getText().length;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((up && !canMoveUp) || (!up && !canMoveDown)) return;
|
if ((up && !canMoveUp) || (!up && !canMoveDown)) return;
|
||||||
|
|
Loading…
Reference in New Issue