import { IEditor, IServiceID } from "../../../types/kernel.js"; import "../../../types/index.js"; import { LexicalNode } from "lexical"; interface IBlockMenuRenderContext { blockElement: HTMLElement; blockId: string; editor: IEditor; } interface IBlockMenuItem { key: string; label: string | ((context: IBlockMenuRenderContext) => string); onClick: (context: IBlockMenuRenderContext) => void; order?: number; when?: (context: IBlockMenuRenderContext) => boolean; } type IBlockActionButtonIcon = 'plus'; interface IBlockActionButton { icon?: IBlockActionButtonIcon; key: string; onClick: (context: IBlockMenuRenderContext) => void; order?: number; title: string | ((context: IBlockMenuRenderContext) => string); when?: (context: IBlockMenuRenderContext) => boolean; } interface IBlockSelectHandler { key: string; onSelect: (node: LexicalNode) => boolean | void; order?: number; } interface IBlockMenuService { getActionButtons(context: IBlockMenuRenderContext): IBlockActionButton[]; /** * Returns the currently pinned menu context, or null when no lock is active. * While locked, the block menu UI freezes at the pinned block and hover * detection no longer reassigns the anchor. */ getMenuLockedContext(): IBlockMenuRenderContext | null; getMenus(context: IBlockMenuRenderContext): IBlockMenuItem[]; isMenuSuppressed(): boolean; registerActionButton(item: IBlockActionButton): () => void; registerMenu(item: IBlockMenuItem): () => void; registerSelectHandler(item: IBlockSelectHandler): () => void; selectNode(node: LexicalNode): boolean; /** * Pin the block menu UI to the provided context (typically while a consumer * popup spawned by an action button is open). Pass `null` for `context` to * release the lock owned by `key`. Multiple keys may hold locks * simultaneously; the most recently set lock wins. */ setMenuLockedContext(key: string, context: IBlockMenuRenderContext | null): void; setMenuSuppressed(key: string, suppressed: boolean): void; subscribe(listener: () => void): () => void; } declare const IBlockMenuService: IServiceID; declare class BlockMenuService implements IBlockMenuService { private actionButtons; private items; private listeners; private lockedContexts; private selectHandlers; private suppressors; getActionButtons(context: IBlockMenuRenderContext): IBlockActionButton[]; getMenuLockedContext(): IBlockMenuRenderContext | null; getMenus(context: IBlockMenuRenderContext): IBlockMenuItem[]; isMenuSuppressed(): boolean; registerActionButton(item: IBlockActionButton): () => void; registerMenu(item: IBlockMenuItem): () => void; registerSelectHandler(item: IBlockSelectHandler): () => void; selectNode(node: LexicalNode): boolean; setMenuLockedContext(key: string, context: IBlockMenuRenderContext | null): void; setMenuSuppressed(key: string, suppressed: boolean): void; subscribe(listener: () => void): () => void; private notify; } export { BlockMenuService, IBlockActionButton, IBlockActionButtonIcon, IBlockMenuItem, IBlockMenuRenderContext, IBlockMenuService, IBlockSelectHandler };