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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user