UNPKG

@churchapps/apphelper-markdown

Version:

ChurchApps markdown/lexical editor components

19 lines (18 loc) 703 B
import { useEffect } from "react"; import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext"; import { toggleCustomLinkNode, TOGGLE_CUSTOM_LINK_NODE_COMMAND } from "./CustomLinkNode"; const COMMAND_PRIORITY = 1; const CustomLinkNodePlugin = () => { const [editor] = useLexicalComposerContext(); useEffect(() => { return editor.registerCommand(TOGGLE_CUSTOM_LINK_NODE_COMMAND, (props) => { toggleCustomLinkNode({ ...props, getNodeByKey: (key) => editor.getElementByKey(key) }); return true; }, COMMAND_PRIORITY); }, [editor]); return null; }; export default CustomLinkNodePlugin;