@terrible-lexical/react
Version:
This package provides Lexical components and hooks for React applications.
27 lines (22 loc) • 822 B
text/typescript
/**
* 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 type {LexicalEditor} from 'terrible-lexical';
import {registerDragonSupport} from '@terrible-lexical/dragon/src';
import {registerRichText} from '@terrible-lexical/rich-text/src';
import {mergeRegister} from '@terrible-lexical/utils/src';
import useLayoutEffect from '@terrible-lexical/shared/src/useLayoutEffect';
export function useRichTextSetup(editor: LexicalEditor): void {
useLayoutEffect(() => {
return mergeRegister(
registerRichText(editor),
registerDragonSupport(editor),
);
// We only do this for init
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [editor]);
}