mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-26 17:52:18 +01:00
add ctrl+enter to DM view
This commit is contained in:
parent
53b2c9e399
commit
3939443336
@ -21,7 +21,7 @@ export default function SendMessageForm({ pubkey, ...props }: { pubkey: string }
|
||||
const { getOrCreateContainer } = useDecryptionContext();
|
||||
|
||||
const [loadingMessage, setLoadingMessage] = useState("");
|
||||
const { getValues, setValue, watch, register, handleSubmit, formState, reset } = useForm({
|
||||
const { getValues, setValue, watch, handleSubmit, formState, reset } = useForm({
|
||||
defaultValues: {
|
||||
content: "",
|
||||
},
|
||||
@ -63,8 +63,10 @@ export default function SendMessageForm({ pubkey, ...props }: { pubkey: string }
|
||||
setLoadingMessage("");
|
||||
});
|
||||
|
||||
const formRef = useRef<HTMLFormElement | null>(null);
|
||||
|
||||
return (
|
||||
<Flex as="form" gap="2" {...props}>
|
||||
<Flex as="form" gap="2" onSubmit={sendMessage} ref={formRef} {...props}>
|
||||
{loadingMessage ? (
|
||||
<Heading size="md" mx="auto" my="4">
|
||||
{loadingMessage}
|
||||
@ -80,8 +82,11 @@ export default function SendMessageForm({ pubkey, ...props }: { pubkey: string }
|
||||
isRequired
|
||||
instanceRef={(inst) => (textAreaRef.current = inst)}
|
||||
onPaste={onPaste}
|
||||
onKeyDown={(e) => {
|
||||
if (e.ctrlKey && e.key === "Enter" && formRef.current) formRef.current.requestSubmit();
|
||||
}}
|
||||
/>
|
||||
<Button onClick={sendMessage}>Send</Button>
|
||||
<Button type="submit">Send</Button>
|
||||
</>
|
||||
)}
|
||||
</Flex>
|
||||
|
Loading…
x
Reference in New Issue
Block a user