mirror of
https://github.com/aljazceru/rabbit.git
synced 2025-12-18 22:44:26 +01:00
feat: support Ctrl+Enter post in reply
This commit is contained in:
@@ -25,7 +25,7 @@ const NotePostForm: Component<NotePostFormProps> = (props) => {
|
||||
submit();
|
||||
};
|
||||
|
||||
const handleKeyDown: JSX.EventHandler<HTMLFormElement, KeyboardEvent> = (ev) => {
|
||||
const handleKeyDown: JSX.EventHandlerUnion<HTMLTextAreaElement, KeyboardEvent> = (ev) => {
|
||||
if (ev.key === 'Enter' && (ev.ctrlKey || ev.metaKey)) {
|
||||
submit();
|
||||
}
|
||||
|
||||
@@ -18,13 +18,23 @@ const ReplyPostForm: Component<ReplyPostFormProps> = (props: ReplyPostFormProps)
|
||||
setText(ev.currentTarget.value);
|
||||
};
|
||||
|
||||
const handleSubmit: JSX.EventHandler<HTMLFormElement, Event> = (ev) => {
|
||||
ev.preventDefault();
|
||||
// TODO 投稿完了したかどうかの検知をしたい
|
||||
// TODO 投稿完了したかどうかの検知をしたい
|
||||
const submit = () => {
|
||||
props.onPost({ content: text() });
|
||||
clearText();
|
||||
};
|
||||
|
||||
const handleSubmit: JSX.EventHandler<HTMLFormElement, Event> = (ev) => {
|
||||
ev.preventDefault();
|
||||
submit();
|
||||
};
|
||||
|
||||
const handleKeyDown: JSX.EventHandler<HTMLTextAreaElement, KeyboardEvent> = (ev) => {
|
||||
if (ev.key === 'Enter' && (ev.ctrlKey || ev.metaKey)) {
|
||||
submit();
|
||||
}
|
||||
};
|
||||
|
||||
const submitDisabled = createMemo(() => text().trim().length === 0);
|
||||
|
||||
return (
|
||||
@@ -40,6 +50,7 @@ const ReplyPostForm: Component<ReplyPostFormProps> = (props: ReplyPostFormProps)
|
||||
rows={4}
|
||||
placeholder="返信を投稿"
|
||||
onInput={handleChangeText}
|
||||
onKeyDown={handleKeyDown}
|
||||
value={text()}
|
||||
/>
|
||||
<div class="flex justify-between">
|
||||
|
||||
Reference in New Issue
Block a user