@lexical/react
Version:
This package provides Lexical components and hooks for React applications.
11 lines (9 loc) • 979 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{getExtensionDependencyFromEditor as e}from"@lexical/extension/getExtensionDependencyFromEditor";import{LexicalBuilder as t}from"@lexical/extension/LexicalBuilder";import{ReactExtension as o}from"@lexical/react/ReactExtension";import{ReactProviderExtension as i}from"@lexical/react/ReactProviderExtension";import{configExtension as r}from"lexical";import{useMemo as n,useEffect as c}from"react";import{jsx as l}from"react/jsx-runtime";function m({extension:m,children:a,contentEditable:x}){const s=n(()=>t.fromExtensions([i,/* @__PURE__ */r(o,void 0===x?{}:{contentEditable:x}),m]).buildEditor(),[x,m]);c(()=>{let e=!1;return queueMicrotask(()=>{e=!0}),()=>{e&&s.dispose()}},[s]);const{Component:d}=e(s,o).output;
return l(d,{children:a})}export{m as LexicalExtensionComposer};