import React from 'react'; import type { LexicalEditorNodeMap, LexicalEditorViewMap } from '../types.js'; /** * Context for managing richtext editor view state and inheritance. */ type RichTextViewContextType = { /** * The currently active view name (e.g., 'default', 'frontend', 'debug'). */ currentView: string; /** * The resolved node map for the current view, containing rendering overrides for each node type. */ currentViewMap?: LexicalEditorNodeMap; /** * True if the current view was explicitly set (via prop) by this provider or an ancestor. * Used to distinguish intentional view settings from automatic defaults. */ hasExplicitCurrentView?: boolean; /** * If true, nested richtext editors will inherit this provider's currentView and views. */ inheritable?: boolean; /** * True if this provider's view is controlled by an ancestor provider — either because the * ancestor has a views map (view-map inheritance) or an explicit `currentView` prop. * When true, the ViewSelector is hidden. */ isControlledByParent?: boolean; /** * Function to programmatically change the current view. */ setCurrentView: (view: string) => void; /** * Map of all available views for this editor. Each key is a view name, each value contains * admin config, node overrides, and lexical config for that view. */ views?: LexicalEditorViewMap; }; /** * Provider for managing richtext editor view state and its inheritance. * * Handles two key scenarios: * 1. **Explicit view setting**: Wrap with `currentView` and `inheritable={true}` to force nested editors to a specific view * 2. **View map inheritance**: Nested editors inherit `views` from parents, allowing view switching across the hierarchy * * When a nested editor inherits from a parent, its ViewSelector is hidden because the view is controlled by an ancestor. * * @example * Force all nested richtext editors to use "frontend" view: * ```tsx * * {/* All richtext fields inside will use "frontend" view } * * ``` */ export declare const RichTextViewProvider: React.FC<{ children: React.ReactNode; currentView?: string; inheritable?: boolean; views?: LexicalEditorViewMap; }>; /** * Access the current richtext editor view context. * * Returns the active view name, node overrides, inheritance state, and a function to switch views. * * @example * ```tsx * function MyComponent() { * const { currentView, currentViewMap, isControlledByParent, setCurrentView } = useRichTextView() * * return ( *
*

Active view: {currentView}

* {isControlledByParent &&

View controlled by parent

} * {currentViewMap?.heading &&

Custom heading renderer active

} * *
* ) * } * ``` */ export declare function useRichTextView(): RichTextViewContextType; export {}; //# sourceMappingURL=RichTextViewProvider.d.ts.map