Path: blob/main/src/vs/base/browser/ui/hover/hoverDelegate.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import type { IHoverWidget, IManagedHoverContentOrFactory, IManagedHoverOptions } from './hover.js';6import { HoverPosition } from './hoverWidget.js';7import { IMarkdownString } from '../../../common/htmlContent.js';8import { IDisposable } from '../../../common/lifecycle.js';910export interface IHoverDelegateTarget extends IDisposable {11readonly targetElements: readonly HTMLElement[];12x?: number;13}1415export interface IHoverDelegateOptions extends IManagedHoverOptions {16/**17* The content to display in the primary section of the hover. The type of text determines the18* default `hideOnHover` behavior.19*/20content: IMarkdownString | string | HTMLElement;21/**22* The target for the hover. This determines the position of the hover and it will only be23* hidden when the mouse leaves both the hover and the target. A HTMLElement can be used for24* simple cases and a IHoverDelegateTarget for more complex cases where multiple elements and/or a25* dispose method is required.26*/27target: IHoverDelegateTarget | HTMLElement;28/**29* The container to pass to {@link IContextViewProvider.showContextView} which renders the hover30* in. This is particularly useful for more natural tab focusing behavior, where the hover is31* created as the next tab index after the element being hovered and/or to workaround the32* element's container hiding on `focusout`.33*/34container?: HTMLElement;35/**36* Options that defines where the hover is positioned.37*/38position?: {39/**40* Position of the hover. The default is to show above the target. This option will be ignored41* if there is not enough room to layout the hover in the specified position, unless the42* forcePosition option is set.43*/44hoverPosition?: HoverPosition;45};46appearance?: {47/**48* Whether to show the hover pointer49*/50showPointer?: boolean;51/**52* When {@link hideOnHover} is explicitly true or undefined and its auto value is detected to53* hide, show a hint at the bottom of the hover explaining how to mouse over the widget. This54* should be used in the cases where despite the hover having no interactive content, it's55* likely the user may want to interact with it somehow.56*/57showHoverHint?: boolean;58/**59* Whether to skip the fade in animation, this should be used when hovering from one hover to60* another in the same group so it looks like the hover is moving from one element to the other.61*/62skipFadeInAnimation?: boolean;63};64}6566export interface IHoverDelegate {67showHover(options: IHoverDelegateOptions, focus?: boolean): IHoverWidget | undefined;68onDidHideHover?: () => void;69delay: number | ((content?: IManagedHoverContentOrFactory) => number);70placement?: 'mouse' | 'element';71showNativeHover?: boolean; // TODO@benibenj remove this, only temp fix for contextviews72}7374export interface IScopedHoverDelegate extends IHoverDelegate, IDisposable { }757677