Add CTRL + ENTER to force send message.

Fix: cursor jumping to the end of message area.
Fix: inconsistent message send button on mobile.
This commit is contained in:
Paul
2021-08-30 18:01:32 +01:00
parent 648f0bbf73
commit 08c963e715
5 changed files with 36 additions and 19 deletions

View File

@@ -3,7 +3,7 @@ import Axios, { CancelTokenSource } from "axios";
import { observer } from "mobx-react-lite";
import { ChannelPermission } from "revolt.js/dist/api/permissions";
import { Channel } from "revolt.js/dist/maps/Channels";
import styled from "styled-components";
import styled, { css } from "styled-components";
import { ulid } from "ulid";
import { Text } from "preact-i18n";
@@ -99,11 +99,13 @@ const Action = styled.div`
padding: 12px;
}
.mobile {
@media (pointer: fine) {
display: none;
}
}
${() =>
!isTouchscreenDevice &&
css`
.mobile {
display: none;
}
`}
`;
// For sed replacement
@@ -503,6 +505,11 @@ export default observer(({ channel }: Props) => {
value={draft ?? ""}
padding="var(--message-box-padding)"
onKeyDown={(e) => {
if (e.ctrlKey && e.key === "Enter") {
e.preventDefault();
return send();
}
if (onKeyDown(e)) return;
if (