From 7a08d61d889328ff5e3b8ba61faab71a5568df2f Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 1 Nov 2024 03:45:55 +0000 Subject: Thread composer UI (#6050) * Basic adding of posts * Switch active post on focus * Conditionally show plus button * Insert posts midthread * Track active/inactive post * Delete posts in a thread * Focus after deletion * Tweak empty post detection * Mix height for active only * Move toolbar with post on web * Fix footer positioning * Post All button * Fix reply to positioning * Improve memoization * Improve memoization for clearVideo * Remove unnecessary argument * Add some manual memoization to fix re-renders * Scroll to bottom on add new * Fix opacity on Android * Add backdrop * Fix videos * Check alt for video too * Clear pending publish on error * Fork alt message by type * Separate placeholder for next posts * Limit hitslop to avoid clashes --- src/view/com/composer/text-input/TextInput.web.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/view/com/composer/text-input') diff --git a/src/view/com/composer/text-input/TextInput.web.tsx b/src/view/com/composer/text-input/TextInput.web.tsx index 9da220c1b..f4cb004ed 100644 --- a/src/view/com/composer/text-input/TextInput.web.tsx +++ b/src/view/com/composer/text-input/TextInput.web.tsx @@ -47,6 +47,7 @@ interface TextInputProps { onPressPublish: (richtext: RichText) => void onNewLink: (uri: string) => void onError: (err: string) => void + onFocus: () => void } export const TextInput = React.forwardRef(function TextInputImpl( @@ -58,6 +59,7 @@ export const TextInput = React.forwardRef(function TextInputImpl( onPhotoPasted, onPressPublish, onNewLink, + onFocus, }: // onError, TODO TextInputProps, ref, @@ -149,6 +151,9 @@ export const TextInput = React.forwardRef(function TextInputImpl( const editor = useEditor( { extensions, + onFocus() { + onFocus?.() + }, editorProps: { attributes: { class: modeClass, @@ -244,8 +249,12 @@ export const TextInput = React.forwardRef(function TextInputImpl( }, [onEmojiInserted]) React.useImperativeHandle(ref, () => ({ - focus: () => {}, // TODO - blur: () => {}, // TODO + focus: () => { + editor?.chain().focus() + }, + blur: () => { + editor?.chain().blur() + }, getCursorPosition: () => { const pos = editor?.state.selection.$anchor.pos return pos ? editor?.view.coordsAtPos(pos) : undefined -- cgit 1.4.1