@lexical/react
Version:
This package provides Lexical components and hooks for React applications.
10 lines (8 loc) • 657 B
JavaScript
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import{namedSignals as r}from"@lexical/extension";import{LinkNode as t,registerLink as e}from"@lexical/link";import{useLexicalComposerContext as o}from"@lexical/react/LexicalComposerContext";import{useEffect as i}from"react";function l({validateUrl:l,attributes:n}){const[a]=o();return i(()=>{if(!a.hasNodes([t]))throw new Error("LinkPlugin: LinkNode not registered on editor")}),i(()=>e(a,r({attributes:n,validateUrl:l})),[a,l,n]),null}export{l as LinkPlugin};