mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-26 17:52:18 +01:00
add ctrl+enter to reply and post form
This commit is contained in:
parent
3939443336
commit
4167406d42
@ -158,6 +158,8 @@ export default function PostModal({
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: wrap this in a form
|
||||
return (
|
||||
<>
|
||||
{requireSubject && <Input {...register("subject", { required: true })} isRequired placeholder="Subject" />}
|
||||
@ -170,6 +172,9 @@ export default function PostModal({
|
||||
isRequired
|
||||
instanceRef={(inst) => (textAreaRef.current = inst)}
|
||||
onPaste={onPaste}
|
||||
onKeyDown={(e) => {
|
||||
if (e.ctrlKey && e.key === "Enter") submit();
|
||||
}}
|
||||
/>
|
||||
{getValues().content.length > 0 && (
|
||||
<Box>
|
||||
|
@ -95,8 +95,10 @@ export default function ReplyForm({ item, onCancel, onSubmitted, replyKind = Kin
|
||||
}
|
||||
});
|
||||
|
||||
const formRef = useRef<HTMLFormElement | null>(null);
|
||||
|
||||
return (
|
||||
<Flex as="form" direction="column" gap="2" pb="4" onSubmit={submit}>
|
||||
<Flex as="form" direction="column" gap="2" pb="4" onSubmit={submit} ref={formRef}>
|
||||
<MagicTextArea
|
||||
placeholder="Reply"
|
||||
autoFocus
|
||||
@ -110,6 +112,9 @@ export default function ReplyForm({ item, onCancel, onSubmitted, replyKind = Kin
|
||||
const imageFile = Array.from(e.clipboardData.files).find((f) => f.type.includes("image"));
|
||||
if (imageFile) uploadImage(imageFile);
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.ctrlKey && e.key === "Enter" && formRef.current) formRef.current.requestSubmit();
|
||||
}}
|
||||
/>
|
||||
<Flex gap="2" alignItems="center">
|
||||
<VisuallyHiddenInput
|
||||
|
Loading…
x
Reference in New Issue
Block a user