/** * 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 { EditorState, SerializedEditorState } from './LexicalEditorState'; import type { DOMConversion, LexicalNode, NodeKey } from './LexicalNode'; export declare type Spread = Omit & T1; export declare type Klass = { new (...args: any[]): T; } & Omit; export declare type EditorThemeClassName = string; export declare type TextNodeThemeClasses = { base?: EditorThemeClassName; bold?: EditorThemeClassName; code?: EditorThemeClassName; italic?: EditorThemeClassName; strikethrough?: EditorThemeClassName; subscript?: EditorThemeClassName; superscript?: EditorThemeClassName; underline?: EditorThemeClassName; underlineStrikethrough?: EditorThemeClassName; }; export declare type EditorUpdateOptions = { onUpdate?: () => void; skipTransforms?: true; tag?: string; }; export declare type EditorSetOptions = { tag?: string; }; export declare type EditorFocusOptions = { defaultSelection?: 'rootStart' | 'rootEnd'; }; export declare type EditorThemeClasses = { characterLimit?: EditorThemeClassName; code?: EditorThemeClassName; codeHighlight?: Record; hashtag?: EditorThemeClassName; heading?: { h1?: EditorThemeClassName; h2?: EditorThemeClassName; h3?: EditorThemeClassName; h4?: EditorThemeClassName; h5?: EditorThemeClassName; h6?: EditorThemeClassName; }; image?: EditorThemeClassName; link?: EditorThemeClassName; list?: { ul?: EditorThemeClassName; ulDepth?: Array; ol?: EditorThemeClassName; olDepth?: Array; listitem?: EditorThemeClassName; listitemChecked?: EditorThemeClassName; listitemUnchecked?: EditorThemeClassName; nested?: { list?: EditorThemeClassName; listitem?: EditorThemeClassName; }; }; ltr?: EditorThemeClassName; mark?: EditorThemeClassName; markOverlap?: EditorThemeClassName; paragraph?: EditorThemeClassName; quote?: EditorThemeClassName; root?: EditorThemeClassName; rtl?: EditorThemeClassName; table?: EditorThemeClassName; tableCell?: EditorThemeClassName; tableCellHeader?: EditorThemeClassName; tableRow?: EditorThemeClassName; text?: TextNodeThemeClasses; embedBlock?: { base?: EditorThemeClassName; focus?: EditorThemeClassName; }; [key: string]: any; }; export declare type EditorConfig = { disableEvents?: boolean; namespace: string; theme: EditorThemeClasses; }; export declare type RegisteredNodes = Map; export declare type RegisteredNode = { klass: Klass; transforms: Set>; }; export declare type Transform = (node: T) => void; export declare type ErrorHandler = (error: Error) => void; export declare type MutationListeners = Map>; export declare type MutatedNodes = Map, Map>; export declare type NodeMutation = 'created' | 'updated' | 'destroyed'; export declare type UpdateListener = (arg0: { dirtyElements: Map; dirtyLeaves: Set; editorState: EditorState; normalizedNodes: Set; prevEditorState: EditorState; tags: Set; }) => void; export declare type DecoratorListener = (decorator: Record) => void; export declare type RootListener = (rootElement: null | HTMLElement, prevRootElement: null | HTMLElement) => void; export declare type TextContentListener = (text: string) => void; export declare type MutationListener = (nodes: Map, payload: { updateTags: Set; dirtyLeaves: Set; }) => void; export declare type CommandListener

= (payload: P, editor: LexicalEditor) => boolean; export declare type ReadOnlyListener = (readOnly: boolean) => void; export declare type CommandListenerPriority = 0 | 1 | 2 | 3 | 4; export declare const COMMAND_PRIORITY_EDITOR = 0; export declare const COMMAND_PRIORITY_LOW = 1; export declare const COMMAND_PRIORITY_NORMAL = 2; export declare const COMMAND_PRIORITY_HIGH = 3; export declare const COMMAND_PRIORITY_CRITICAL = 4; export declare type LexicalCommand = Record; /** * Type helper for extracting the payload type from a command. * * @example * ```ts * const MY_COMMAND = createCommand(); * * // ... * * editor.registerCommand(MY_COMMAND, payload => { * // Type of `payload` is inferred here. But lets say we want to extract a function to delegate to * handleMyCommand(editor, payload); * return true; * }); * * function handleMyCommand(editor: LexicalEditor, payload: CommandPayloadType) { * // `payload` is of type `SomeType`, extracted from the command. * } * ``` */ export declare type CommandPayloadType> = TCommand extends LexicalCommand ? TPayload : never; declare type Commands = Map, Array>>>; declare type Listeners = { decorator: Set; mutation: MutationListeners; readonly: Set; root: Set; textcontent: Set; update: Set; }; export declare type Listener = DecoratorListener | ReadOnlyListener | MutationListener | RootListener | TextContentListener | UpdateListener; export declare type ListenerType = 'update' | 'root' | 'decorator' | 'textcontent' | 'mutation' | 'readonly'; export declare type TransformerType = 'text' | 'decorator' | 'element' | 'root'; export declare type IntentionallyMarkedAsDirtyElement = boolean; declare type DOMConversionCache = Map DOMConversion | null>>; export declare type SerializedEditor = { editorState: SerializedEditorState; }; export declare function resetEditor(editor: LexicalEditor, prevRootElement: null | HTMLElement, nextRootElement: null | HTMLElement, pendingEditorState: EditorState): void; export declare function createEditor(editorConfig?: { disableEvents?: boolean; editorState?: EditorState; namespace?: string; nodes?: ReadonlyArray>; onError?: ErrorHandler; parentEditor?: LexicalEditor; readOnly?: boolean; theme?: EditorThemeClasses; }): LexicalEditor; export declare class LexicalEditor { _headless: boolean; _parentEditor: null | LexicalEditor; _rootElement: null | HTMLElement; _editorState: EditorState; _pendingEditorState: null | EditorState; _compositionKey: null | NodeKey; _deferred: Array<() => void>; _keyToDOMMap: Map; _updates: Array<[() => void, EditorUpdateOptions | undefined]>; _updating: boolean; _listeners: Listeners; _commands: Commands; _nodes: RegisteredNodes; _decorators: Record; _pendingDecorators: null | Record; _config: EditorConfig; _dirtyType: 0 | 1 | 2; _cloneNotNeeded: Set; _dirtyLeaves: Set; _dirtyElements: Map; _normalizedNodes: Set; _updateTags: Set; _observer: null | MutationObserver; _key: string; _onError: ErrorHandler; _htmlConversions: DOMConversionCache; _readOnly: boolean; constructor(editorState: EditorState, parentEditor: null | LexicalEditor, nodes: RegisteredNodes, config: EditorConfig, onError: ErrorHandler, htmlConversions: DOMConversionCache, readOnly: boolean); isComposing(): boolean; registerUpdateListener(listener: UpdateListener): () => void; registerReadOnlyListener(listener: ReadOnlyListener): () => void; registerDecoratorListener(listener: DecoratorListener): () => void; registerTextContentListener(listener: TextContentListener): () => void; registerRootListener(listener: RootListener): () => void; registerCommand

(command: LexicalCommand

, listener: CommandListener

, priority: CommandListenerPriority): () => void; registerMutationListener(klass: Klass, listener: MutationListener): () => void; registerNodeTransform(klass: Klass, listener: Transform): () => void; hasNodes>(nodes: Array): boolean; dispatchCommand, TPayload extends CommandPayloadType>(type: TCommand, payload: TPayload): boolean; getDecorators(): Record; getRootElement(): null | HTMLElement; getKey(): string; setRootElement(nextRootElement: null | HTMLElement): void; getElementByKey(key: NodeKey): HTMLElement | null; getEditorState(): EditorState; setEditorState(editorState: EditorState, options?: EditorSetOptions): void; parseEditorState(maybeStringifiedEditorState: string | SerializedEditorState, updateFn?: () => void): EditorState; update(updateFn: () => void, options?: EditorUpdateOptions): void; focus(callbackFn?: () => void, options?: EditorFocusOptions): void; blur(): void; isReadOnly(): boolean; setReadOnly(readOnly: boolean): void; toJSON(): SerializedEditor; } export {};