UNPKG

@lexical/react

Version:

This package provides Lexical components and hooks for React applications.

10 lines (8 loc) • 670 B
/** * 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/namedSignals";import{LinkNode as t,registerLink as e}from"@lexical/link";import{useLexicalComposerContext as i}from"@lexical/react/LexicalComposerContext";import{useEffect as o}from"react";function n({validateUrl:n,attributes:l}){const[a]=i();return o(()=>{if(!a.hasNodes([t]))throw new Error("LinkPlugin: LinkNode not registered on editor")}),o(()=>e(a,r({attributes:l,validateUrl:n})),[a,n,l]),null}export{n as LinkPlugin};