/** * 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 LexicalNode } from 'lexical'; import { type JSX, type RefObject } from 'react'; declare class MenuOption { key: string; ref?: RefObject; constructor(key: string); setRefElement(element: HTMLElement | null): void; } /** * A selectable item in a {@link NodeContextMenuPlugin}. It pairs a `title` (and * optional `icon`/`disabled` state) with a `$onSelect` callback that runs in an * editor update when chosen, and an optional `$showOn` predicate that decides, * per node, whether the item is shown for the right-clicked node. */ declare class NodeContextMenuOption extends MenuOption { type: string; title: string; icon: JSX.Element | null; disabled: boolean; $onSelect: () => void; $showOn?: (node: LexicalNode) => boolean; constructor(title: string, options: { disabled?: boolean; icon?: JSX.Element; $onSelect: () => void; $showOn?: (node: LexicalNode) => boolean; }); } /** * A non-interactive divider between groups of {@link NodeContextMenuOption}s in * a {@link NodeContextMenuPlugin}. Like menu options, it accepts an optional * `$showOn` predicate to control when it is displayed. */ declare class NodeContextMenuSeparator extends MenuOption { type: string; $showOn?: (node: LexicalNode) => boolean; constructor(options?: { $showOn?: (node: LexicalNode) => boolean; }); } type ContextMenuType = NodeContextMenuOption | NodeContextMenuSeparator; interface Props { label?: string; nested?: boolean; itemClassName?: string; separatorClassName?: string; items: ContextMenuType[]; } /** * Renders a custom context menu (replacing the browser's) when the user * right-clicks inside the editor. Pass the `items` to display as * {@link NodeContextMenuOption}s and {@link NodeContextMenuSeparator}s; each * item's optional `$showOn` predicate is evaluated against the node nearest the * click so the menu can adapt to its target. Supports keyboard navigation and * type-ahead. * * @returns A portal containing the floating context menu while it is open. */ declare const NodeContextMenuPlugin: import("react").ForwardRefExoticComponent, "ref"> & import("react").RefAttributes>; export { NodeContextMenuOption, NodeContextMenuPlugin, NodeContextMenuSeparator };