import { StandardMouseEvent } from "./mouseEvent.js"; import { IActionViewItemOptions } from "./ui/actionbar/actionViewItems.js"; import { IActionViewItem } from "./ui/actionbar/actionbar.js"; import { AnchorAlignment, AnchorAxisAlignment, IAnchor, IContextViewCloseAnimation } from "./ui/contextview/contextview.js"; import { IAction, IActionRunner } from "../common/actions.js"; import { ResolvedKeybinding } from "../common/keybindings.js"; import { OmitOptional } from "../common/types.js"; export interface IContextMenuEvent { readonly shiftKey?: boolean; readonly ctrlKey?: boolean; readonly altKey?: boolean; readonly metaKey?: boolean; } /** * A specific context menu location to position the menu at. * Uses some TypeScript type tricks to prevent allowing to * pass in a `MouseEvent` and force people to use `StandardMouseEvent`. */ type ContextMenuLocation = OmitOptional & { getModifierState?: never; }; export interface IContextMenuDelegate { /** * The anchor where to position the context view. * Use a `HTMLElement` to position the view at the element, * a `StandardMouseEvent` to position it at the mouse position * or an `ContextMenuLocation` to position it at a specific location. */ getAnchor(): HTMLElement | StandardMouseEvent | ContextMenuLocation; getActions(): readonly IAction[]; getCheckedActionsRepresentation?(action: IAction): "radio" | "checkbox"; getActionViewItem?(action: IAction, options: IActionViewItemOptions): IActionViewItem | undefined; getActionsContext?(event?: IContextMenuEvent): unknown; getKeyBinding?(action: IAction): ResolvedKeybinding | undefined; getMenuClassName?(): string; onHide?(didCancel: boolean): void; closeAnimation?: IContextViewCloseAnimation; actionRunner?: IActionRunner; skipTelemetry?: boolean; /** * `true` focuses the first enabled action; `false` or `undefined` leaves the menu without a selection. * A number selects a zero-based index in {@link getActions}, counting separators and each submenu as one item; non-integer or out-of-range indices are ignored. */ autoSelectItem?: boolean | number; anchorAlignment?: AnchorAlignment; anchorAxisAlignment?: AnchorAxisAlignment; domForShadowRoot?: HTMLElement; /** * Mount the shadow root in the window container instead of `domForShadowRoot`. * Use this when the provided element is inside a stacking context that cannot contain the menu. */ useWindowContainerForShadowRoot?: boolean; /** * Host the menu inside `domForShadowRoot` (its owner) as a popover in the top layer, * so focus stays inside the owner while the menu renders unclipped. Requires * `domForShadowRoot` and is ignored together with `useWindowContainerForShadowRoot`. */ hostAsPopover?: boolean; /** * custom context menus with higher layers are rendered higher in z-index order */ layer?: number; } export interface IContextMenuProvider { showContextMenu(delegate: IContextMenuDelegate): void; } /** Normalizes initial selection consistently for HTML and native context menus. */ export declare function getContextMenuAutoSelectItem(delegate: IContextMenuDelegate, actions: readonly IAction[]): boolean | number; export {};