UNPKG

@lexical/react

Version:

This package provides Lexical components and hooks for React applications.

10 lines (8 loc) • 650 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{$isRootTextContentEmptyCurry as t}from"@lexical/text";import{useLayoutEffect as e,useEffect as o,useState as r}from"react";import{CAN_USE_DOM as i}from"lexical";const s=i?e:o;function a(e,o){const[i,a]=r(()=>e.read("latest",t(e.isComposing(),o)));return s(()=>(a(e.read("latest",t(e.isComposing(),o))),e.registerUpdateListener(({editorState:r})=>{const i=e.isComposing(),s=r.read(t(i,o));a(s)})),[e,o]),i}export{a as useLexicalIsTextContentEmpty};