@lexical/react
Version:
This package provides Lexical components and hooks for React applications.
41 lines (40 loc) • 2.21 kB
TypeScript
/**
* 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 CommandListenerPriority, type TextNode } from 'lexical';
import { type JSX } from 'react';
import { MenuOption, type MenuRenderFn, type MenuResolution, type MenuTextMatch, type TriggerFn } from './shared/LexicalMenu.js';
export { useDynamicPositioning } from './shared/LexicalMenu.js';
export { getScrollParent, PUNCTUATION, SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, useBasicTypeaheadTriggerMatch, } from '@lexical/react/LexicalTypeaheadMenuPluginUtils';
/**
* Props for the {@link LexicalTypeaheadMenuPlugin} component.
*/
export type TypeaheadMenuPluginProps<TOption extends MenuOption> = {
onQueryChange: (matchingString: string | null) => void;
onSelectOption: (option: TOption, textNodeContainingQuery: TextNode | null, closeMenu: () => void, matchingString: string) => void;
options: TOption[];
triggerFn: TriggerFn;
menuRenderFn?: MenuRenderFn<TOption>;
onOpen?: (resolution: MenuResolution) => void;
onClose?: () => void | PromiseLike<void>;
anchorClassName?: string;
commandPriority?: CommandListenerPriority;
parent?: HTMLElement;
preselectFirstItem?: boolean;
ignoreEntityBoundary?: boolean;
};
/**
* Renders a floating menu (such as an `@`-mention or slash-command picker) while
* the text before the cursor matches `triggerFn`. As the user types, the
* current query is reported via `onQueryChange`; supply the `options` to show
* and an `onSelectOption` handler to apply the chosen option. Use
* {@link useBasicTypeaheadTriggerMatch} to build a simple `triggerFn`.
*
* @returns The floating menu element, or `null` when no query is active.
*/
export declare function LexicalTypeaheadMenuPlugin<TOption extends MenuOption>({ options, onQueryChange, onSelectOption, onOpen, onClose, menuRenderFn, triggerFn, anchorClassName, commandPriority, parent, preselectFirstItem, ignoreEntityBoundary, }: TypeaheadMenuPluginProps<TOption>): JSX.Element | null;
export { MenuOption, MenuRenderFn, MenuResolution, MenuTextMatch, TriggerFn };