clean up onVerticalArrow
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
6a10f0068d
commit
03c37821f6
1 changed files with 14 additions and 14 deletions
|
@ -1206,15 +1206,22 @@ export default class MessageComposerInput extends React.Component {
|
||||||
onVerticalArrow = (e, up) => {
|
onVerticalArrow = (e, up) => {
|
||||||
if (e.ctrlKey || e.shiftKey || e.metaKey) return;
|
if (e.ctrlKey || e.shiftKey || e.metaKey) return;
|
||||||
|
|
||||||
// Select history
|
if (e.altKey) {
|
||||||
const selection = this.state.editorState.selection;
|
// Try select composer history
|
||||||
|
const selected = this.selectHistory(up);
|
||||||
|
if (selected) {
|
||||||
|
// We're selecting history, so prevent the key event from doing anything else
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
} else if (!e.altKey && up) {
|
||||||
|
// Try edit the latest message
|
||||||
|
const selection = this.state.editorState.selection;
|
||||||
|
|
||||||
// selection must be collapsed
|
// selection must be collapsed
|
||||||
if (!selection.isCollapsed) return;
|
if (!selection.isCollapsed) return;
|
||||||
const document = this.state.editorState.document;
|
const document = this.state.editorState.document;
|
||||||
|
|
||||||
// and we must be at the edge of the document (up=start, down=end)
|
// and we must be at the edge of the document (up=start, down=end)
|
||||||
if (up) {
|
|
||||||
if (!selection.anchor.isAtStartOfNode(document)) return;
|
if (!selection.anchor.isAtStartOfNode(document)) return;
|
||||||
|
|
||||||
if (!e.altKey) {
|
if (!e.altKey) {
|
||||||
|
@ -1227,15 +1234,8 @@ export default class MessageComposerInput extends React.Component {
|
||||||
event: editEvent,
|
event: editEvent,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const selected = this.selectHistory(up);
|
|
||||||
if (selected) {
|
|
||||||
// We're selecting history, so prevent the key event from doing anything else
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
selectHistory = async (up) => {
|
selectHistory = async (up) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue