diff options
Diffstat (limited to 'src/view/com/composer/text-input')
-rw-r--r-- | src/view/com/composer/text-input/TextInput.web.tsx | 13 |
1 files changed, 11 insertions, 2 deletions
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 |