UNPKG

2.84 kBTypeScriptView Raw
1/**
2 * A namespace for `HoverBox` members.
3 */
4export declare namespace HoverBox {
5 /**
6 * Options for setting the geometry of a hovering node and its anchor node.
7 */
8 interface IOptions {
9 /**
10 * The referent anchor rectangle to which the hover box is bound.
11 *
12 * #### Notes
13 * In an editor context, this value will typically be the cursor's
14 * coordinate position, which can be retrieved via calling the
15 * `getCoordinateForPosition` method.
16 */
17 anchor: ClientRect;
18 /**
19 * The node that hosts the anchor.
20 *
21 * #### Notes
22 * The visibility of the anchor rectangle within this host node is the
23 * heuristic that determines whether the hover box ought to be visible.
24 */
25 host: HTMLElement;
26 /**
27 * The maximum height of a hover box.
28 *
29 * #### Notes
30 * This value is only used if a CSS max-height attribute is not set for the
31 * hover box. It is a fallback value.
32 */
33 maxHeight: number;
34 /**
35 * The minimum height of a hover box.
36 */
37 minHeight: number;
38 /**
39 * The hover box node.
40 */
41 node: HTMLElement;
42 /**
43 * Optional pixel offset values added to where the hover box should render.
44 *
45 * #### Notes
46 * This option is useful for passing in values that may pertain to CSS
47 * borders or padding in cases where the text inside the hover box may need
48 * to align with the text of the referent editor.
49 *
50 * Because the hover box calculation may render a box either above or below
51 * the cursor, the `vertical` offset accepts `above` and `below` values for
52 * the different render modes.
53 */
54 offset?: {
55 horizontal?: number;
56 vertical?: {
57 above?: number;
58 below?: number;
59 };
60 };
61 /**
62 * If space is available both above and below the anchor, denote which
63 * location is privileged. Use forceBelow and forceAbove to mandate where
64 * hover box should render relative to anchor.
65 *
66 * #### Notes
67 * The default value is `'below'`.
68 */
69 privilege?: 'above' | 'below' | 'forceAbove' | 'forceBelow';
70 /**
71 * If the style of the node has already been computed, it can be passed into
72 * the hover box for geometry calculation.
73 */
74 style?: CSSStyleDeclaration;
75 }
76 /**
77 * Set the visible dimensions of a hovering box anchored to an editor cursor.
78 *
79 * @param options - The hover box geometry calculation options.
80 */
81 function setGeometry(options: IOptions): void;
82}