diff --git a/src/components/Config.tsx b/src/components/Config.tsx index 7bedaf4..2486ce1 100644 --- a/src/components/Config.tsx +++ b/src/components/Config.tsx @@ -106,6 +106,53 @@ const DateFormatConfig = () => { ); }; +const ToggleButton = (props: { + value: boolean; + onClick: JSX.EventHandler; +}) => { + return ( + + ); +}; + +const OtherConfig = () => { + const { config, setConfig } = useConfig(); + + const toggleKeepOpenPostForm = () => { + setConfig((current) => ({ + ...current, + keepOpenPostForm: !(current.keepOpenPostForm ?? false), + })); + }; + + return ( +
+

その他

+
+
+
投稿欄を開いたままにする
+ toggleKeepOpenPostForm()} + /> +
+
+
+ ); +}; + const ConfigUI = (props: ConfigProps) => { let containerRef: HTMLDivElement | undefined; @@ -131,6 +178,7 @@ const ConfigUI = (props: ConfigProps) => { + ); diff --git a/src/components/NotePostForm.tsx b/src/components/NotePostForm.tsx index 418f1b0..7b01468 100644 --- a/src/components/NotePostForm.tsx +++ b/src/components/NotePostForm.tsx @@ -22,19 +22,21 @@ import eventWrapper from '@/core/event'; import useConfig from '@/nostr/useConfig'; import useCommands from '@/nostr/useCommands'; import usePubkey from '@/nostr/usePubkey'; +import { useHandleCommand } from '@/hooks/useCommandBus'; type NotePostFormProps = { replyTo?: NostrEvent; mode?: 'normal' | 'reply'; onClose: () => void; + onPost?: () => void; + textAreaRef?: (textAreaRef: HTMLTextAreaElement) => void; }; const placeholder = (mode: NotePostFormProps['mode']) => { switch (mode) { - case 'normal': - return 'いまどうしてる?'; case 'reply': return '返信を投稿'; + case 'normal': default: return 'いまどうしてる?'; } @@ -59,7 +61,7 @@ const NotePostForm: Component = (props) => { onSuccess: () => { console.log('succeeded to post'); clearText(); - props?.onClose(); + props.onPost?.(); }, onError: (err) => { console.error('error', err); @@ -99,6 +101,7 @@ const NotePostForm: Component = (props) => { if (ev.key === 'Enter' && (ev.ctrlKey || ev.metaKey)) { submit(); } else if (ev.key === 'Escape') { + textAreaRef?.blur(); props.onClose(); } }; @@ -129,7 +132,10 @@ const NotePostForm: Component = (props) => {