UNPKG

@selfcommunity/react-ui

Version:

React UI Components to integrate a Community created with SelfCommunity Platform.

15 lines (14 loc) 526 B
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'; import { useEffect } from 'react'; import { COMMAND_PRIORITY_EDITOR, FOCUS_COMMAND } from 'lexical'; const OnFocusPlugin = ({ onFocus }) => { const [editor] = useLexicalComposerContext(); useEffect(() => { return editor.registerCommand(FOCUS_COMMAND, (event) => { onFocus && onFocus(event); return true; }, COMMAND_PRIORITY_EDITOR); }, []); return null; }; export default OnFocusPlugin;