Skip to main content

@lexical/react/LexicalComposerContext

Type Aliases

LexicalComposerContextType

LexicalComposerContextType = object

Defined in: packages/lexical-react/src/LexicalComposerContext.ts:20

The context value provided alongside a LexicalEditor by a LexicalComposer. It exposes a getTheme() function that resolves the active EditorThemeClasses, falling back to any parent composer's theme.

Properties

getTheme

getTheme: () => EditorThemeClasses | null | undefined

Defined in: packages/lexical-react/src/LexicalComposerContext.ts:21

Returns

EditorThemeClasses | null | undefined


LexicalComposerContextWithEditor

LexicalComposerContextWithEditor = [LexicalEditor, LexicalComposerContextType]

Defined in: packages/lexical-react/src/LexicalComposerContext.ts:29

A tuple of the LexicalEditor and its LexicalComposerContextType, as stored in LexicalComposerContext and returned by useLexicalComposerContext.

Variables

LexicalComposerContext

const LexicalComposerContext: React.Context<LexicalComposerContextWithEditor | null | undefined>

Defined in: packages/lexical-react/src/LexicalComposerContext.ts:40

The React context used to share the LexicalEditor and its LexicalComposerContextType with descendant plugins and components. Most code should read it through useLexicalComposerContext rather than consuming the context directly.

Functions

createLexicalComposerContext()

createLexicalComposerContext(parent, theme): LexicalComposerContextType

Defined in: packages/lexical-react/src/LexicalComposerContext.ts:56

Creates a LexicalComposerContextType for a composer. Theme resolution falls back to the optional parent context, so nested composers inherit the parent's theme unless they provide their own.

Parameters

parent

LexicalComposerContextWithEditor | null | undefined

The parent composer context to inherit from, if any.

theme

EditorThemeClasses | null | undefined

The theme classes for this composer, or null/undefined to inherit from parent.

Returns

LexicalComposerContextType

The new composer context value.


useLexicalComposerContext()

useLexicalComposerContext(): LexicalComposerContextWithEditor

Defined in: packages/lexical-react/src/LexicalComposerContext.ts:87

Returns the LexicalEditor and its LexicalComposerContextType from the nearest LexicalComposer (or nested composer). This is the primary way plugins and components access the editor instance.

Returns

LexicalComposerContextWithEditor

The [editor, context] tuple for the current composer.

Throws

If called outside of a LexicalComposer.