@terrible-lexical/react
Version:
This package provides Lexical components and hooks for React applications.
30 lines (23 loc) • 780 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 {ListItemNode, ListNode} from '@terrible-lexical/list/src';
import {useLexicalComposerContext} from '@terrible-lexical/react/src/LexicalComposerContext';
import {useEffect} from 'react';
import {useList} from './@terrible-lexical/shared/useList';
export function ListPlugin(): null {
const [editor] = useLexicalComposerContext();
useEffect(() => {
if (!editor.hasNodes([ListNode, ListItemNode])) {
throw new Error(
'ListPlugin: ListNode and/or ListItemNode not registered on editor',
);
}
}, [editor]);
useList(editor);
return null;
}