/** * 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 { AnyContextConfigPairOrUpdater, AnyContextSymbol, ContextConfig, ContextConfigPair, ContextConfigUpdater, ContextRecord } from './types.js'; import { type LexicalEditor } from 'lexical'; type WithContext = { [K in Ctx]?: undefined | ContextRecord; }; /** * @experimental * * The LexicalEditor with context */ export type EditorContext = { editor: LexicalEditor; } & WithContext; /** * @experimental * * @param contextRecord The ContextRecord * @param cfg The configuration * @returns The value or defaultValue of cfg */ export declare function getContextValue(contextRecord: undefined | ContextRecord, cfg: ContextConfig): V; /** * @experimental * * Read and delete cfg from this layer of context * * @param contextRecord The ContextRecord * @param cfg The configuration * @returns The value of the configuration that was removed */ export declare function popOwnContextValue(contextRecord: ContextRecord, cfg: ContextConfig): undefined | V; /** * @experimental * * Get the value without a default * * @param contextRecord The ContextRecord * @param cfg The configuration * @returns The current value in this context or `undefined` if not set */ export declare function getOwnContextValue(contextRecord: ContextRecord, cfg: ContextConfig): undefined | V; /** * @experimental * * @param sym The symbol for this ContextRecord (e.g. DOMRenderContextSymbol) * @param editor The editor * @returns The current context or undefined */ export declare function getContextRecord(sym: Ctx, editor: LexicalEditor): undefined | ContextRecord; /** * Construct a new context from a parent context and pairs * * @param pairs The pairs and updaters to build the context from * @param parent The parent context * @returns The new context */ export declare function contextFromPairs(pairs: readonly AnyContextConfigPairOrUpdater[], parent: undefined | ContextRecord): undefined | ContextRecord; /** * Create a context config pair that sets a value in the render context. * @experimental */ export declare function contextValue(cfg: ContextConfig, value: V): ContextConfigPair; /** * Create a context config updater that transforms a value in the render context. * @experimental */ export declare function contextUpdater(cfg: ContextConfig, updater: (prev: V) => V): ContextConfigUpdater; /** * @internal * @experimental * @__NO_SIDE_EFFECTS__ */ export declare function $withFullContext(sym: Ctx, contextRecord: ContextRecord, f: () => T, editor?: LexicalEditor): T; /** * @internal * @experimental * @__NO_SIDE_EFFECTS__ */ export declare function $withContext(sym: Ctx, $defaults?: (editor: LexicalEditor) => undefined | ContextRecord): (cfg: readonly AnyContextConfigPairOrUpdater[], editor?: LexicalEditor) => ((f: () => T) => T); /** * @experimental * @internal * @__NO_SIDE_EFFECTS__ */ export declare function createContextState(tag: Tag, name: string, getDefaultValue: () => V, isEqual?: (a: V, b: V) => boolean): ContextConfig; export {};