UNPKG

@lexical/react

Version:

This package provides Lexical components and hooks for React applications.

10 lines (8 loc) • 740 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{FocusManagerExtension as r}from"@lexical/a11y";import{getExtensionDependencyFromEditor as t}from"@lexical/extension/getExtensionDependencyFromEditor";import{useLexicalComposerContext as e}from"@lexical/react/LexicalComposerContext";import{useRef as o,useCallback as n}from"react";function l(l={}){const[c]=e(),{toolbarItemSelector:i}=l,m=o(null);return n(e=>{if(null!==m.current&&(m.current(),m.current=null),null!==e){const o=t(c,r);m.current=o.output.register(e,{toolbarItemSelector:i})}},[c,i])}export{l as useLexicalFocusManagerRef};