UNPKG

@lobehub/editor

Version:

A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.

25 lines 772 B
import { createContext as createReactContext, use } from 'react'; import { assert } from "../utils"; export var LexicalComposerContext = /*#__PURE__*/createReactContext(null); export function createLexicalComposerContext(parent, theme) { var parentContext = null; if (parent) { parentContext = parent[1]; } function getTheme() { if (theme !== null) { return theme; } return parentContext !== null ? parentContext.getTheme() : null; } return { getTheme: getTheme }; } export function useLexicalComposerContext() { var composerContext = use(LexicalComposerContext); if (!composerContext) { assert(false, 'LexicalComposerContext.useLexicalComposerContext: cannot find a LexicalComposerContext'); } return composerContext; }