@lexical/react
Version:
This package provides Lexical components and hooks for React applications.
69 lines (56 loc) • 1.97 kB
Flow
/**
* 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.
*
* @flow strict
*/
/**
* LexicalReactExtension
*/
import type {LexicalExtension} from 'lexical';
import type {LexicalComposerContextWithEditor} from '@lexical/react/LexicalComposerContext';
export interface EditorChildrenComponentProps {
context: LexicalComposerContextWithEditor;
contentEditable: null | React.Node;
children?: React.Node;
}
export type EditorChildrenComponentType = (
props: EditorChildrenComponentProps,
) => React.Node | null;
export interface DecoratorComponentProps {
context: LexicalComposerContextWithEditor;
}
export type DecoratorComponentType =
| React.Node
| ((props: DecoratorComponentProps) => React.Node | null);
export type EditorComponentProps = {
EditorChildrenComponent: EditorChildrenComponentType;
children?: React.Node;
contentEditable: React.Node | null;
ErrorBoundary: ErrorBoundaryType;
};
export type EditorComponentType = (
props: Partial<EditorComponentProps>,
) => React.Node;
export type ReactConfig = {
contentEditable: React.Node | null;
ErrorBoundary: ErrorBoundaryType;
EditorChildrenComponent: EditorChildrenComponentType;
decorators: $ReadOnlyArray<DecoratorComponentType>;
};
export type ReactOutputs = {
Component: EditorComponentType;
context: LexicalComposerContextWithEditor;
};
export type ErrorBoundaryProps = {
children: React.Node;
onError: (error: Error) => void;
};
export type ErrorBoundaryType = React.ComponentType<ErrorBoundaryProps>;
declare export function DefaultEditorChildrenComponent(props: EditorChildrenComponentProps): React.Node;
declare export var ReactExtension: LexicalExtension<ReactConfig, "@lexical/react/React", {
Component: (props: Partial<EditorComponentProps>) => React.Node;
context: LexicalComposerContextWithEditor;
}, void>;