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