UNPKG

@lexical/react

Version:

This package provides Lexical components and hooks for React applications.

10 lines (8 loc) 883 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{LexicalBuilder as t,getExtensionDependencyFromEditor as e}from"@lexical/extension";import{ReactExtension as o}from"@lexical/react/ReactExtension";import{ReactProviderExtension as r}from"@lexical/react/ReactProviderExtension";import{configExtension as i}from"lexical";import{useMemo as n,useEffect as c}from"react";import{jsx as m}from"react/jsx-runtime";function l({extension:l,children:a,contentEditable:s}){const x=n(()=>t.fromExtensions([r,i(o,void 0===s?{}:{contentEditable:s}),l]).buildEditor(),[s,l]);c(()=>{let t=!1;return queueMicrotask(()=>{t=!0}),()=>{t&&x.dispose()}},[x]);const{Component:p}=e(x,o).output;return m(p,{children:a})}export{l as LexicalExtensionComposer};