/** * 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 { JSX } from 'react'; import { EditorState, EditorThemeClasses, HTMLConfig, Klass, LexicalEditor, LexicalNode, LexicalNodeReplacement } from 'lexical'; import * as React from 'react'; /** * The initial editor state accepted by {@link LexicalComposer} via * `initialConfig.editorState`. Each variant is handled differently: * * - `null` — skip default initialization entirely. The root is left with no * children for an external owner (typically the * [collaboration plugin](/docs/collaboration/react) and its Yjs document) * to populate. * - `string` — a JSON string produced by serializing an `EditorState`. Parsed * with {@link LexicalEditor.parseEditorState} and applied via * {@link LexicalEditor.setEditorState}. * - `EditorState` — applied directly via {@link LexicalEditor.setEditorState}. * - `(editor) => void` — an updater run inside `editor.update(...)`. Invoked * only when the root is still empty, so it will not overwrite content * bootstrapped by another mechanism, and is silently skipped if the root * already has children. * * Note that `string` and `EditorState` inputs go through `setEditorState`, * which throws when the parsed state satisfies `EditorState.isEmpty()` (root * with no children and no selection). The empty serialization produced by * initializing with `null` and never modifying the editor falls into this * category, so it cannot be re-applied via `setEditorState` after a round-trip. */ export type InitialEditorStateType = null | string | EditorState | ((editor: LexicalEditor) => void); export type InitialConfigType = Readonly<{ namespace: string; nodes?: ReadonlyArray | LexicalNodeReplacement>; onError: (error: Error, editor: LexicalEditor) => void; editable?: boolean; theme?: EditorThemeClasses; /** * The initial state of the editor. Read once on mount; changes after the * first render are ignored. * * Omitting the field (or passing `undefined`) seeds the root with a default * empty `ParagraphNode`. Pass `null` to skip that default — required when * pairing with the collaboration plugin so that the Yjs document, not * Lexical, owns the initial content. See {@link InitialEditorStateType} * for the full set of accepted shapes. */ editorState?: InitialEditorStateType; html?: HTMLConfig; }>; type Props = React.PropsWithChildren<{ initialConfig: InitialConfigType; }>; export declare function LexicalComposer({ initialConfig, children }: Props): JSX.Element; export {};