UNPKG

@tohuhono/puck-rich-text

Version:

A puck component for rich text editing made for OberonCMS

18 lines (17 loc) 418 B
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext"; import { useEffect } from "react"; const FocusPlugin = ({ enabled }) => { const [editor] = useLexicalComposerContext(); useEffect(() => { if (enabled) { editor.setEditable(true); editor.focus(); return; } editor.setEditable(false); }, [enabled, editor]); return null; }; export { FocusPlugin };