UNPKG

@lexical/react

Version:

This package provides Lexical components and hooks for React applications.

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