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