UNPKG

3.99 kBTypeScriptView Raw
1type OutOfViewDisplay = 'hidden-inside' | 'hidden-outside' | 'stick-inside' | 'stick-outside';
2/**
3 * A namespace for `HoverBox` members.
4 */
5export declare namespace HoverBox {
6 /**
7 * Options for setting the geometry of a hovering node and its anchor node.
8 */
9 interface IOptions {
10 /**
11 * The referent anchor rectangle to which the hover box is bound.
12 *
13 * #### Notes
14 * In an editor context, this value will typically be the cursor's
15 * coordinate position, which can be retrieved via calling the
16 * `getCoordinateForPosition` method.
17 */
18 anchor: IAnchor;
19 /**
20 * The node that hosts the anchor.
21 *
22 * #### Notes
23 * The visibility of the elements under hover box edges within this host
24 * node is the heuristic that determines whether the hover box ought to be
25 * visible.
26 */
27 host: HTMLElement;
28 /**
29 * The maximum height of a hover box.
30 *
31 * #### Notes
32 * This value is only used if a CSS max-height attribute is not set for the
33 * hover box. It is a fallback value.
34 */
35 maxHeight: number;
36 /**
37 * The minimum height of a hover box.
38 */
39 minHeight: number;
40 /**
41 * The hover box node.
42 */
43 node: HTMLElement;
44 /**
45 * Optional pixel offset values added to where the hover box should render.
46 *
47 * #### Notes
48 * This option is useful for passing in values that may pertain to CSS
49 * borders or padding in cases where the text inside the hover box may need
50 * to align with the text of the referent editor.
51 *
52 * Because the hover box calculation may render a box either above or below
53 * the cursor, the `vertical` offset accepts `above` and `below` values for
54 * the different render modes.
55 */
56 offset?: {
57 horizontal?: number;
58 vertical?: {
59 above?: number;
60 below?: number;
61 };
62 };
63 /**
64 * If space is available both above and below the anchor, denote which
65 * location is privileged. Use forceBelow and forceAbove to mandate where
66 * hover box should render relative to anchor.
67 *
68 * #### Notes
69 * The default value is `'below'`.
70 */
71 privilege?: 'above' | 'below' | 'forceAbove' | 'forceBelow';
72 /**
73 * If the style of the node has already been computed, it can be passed into
74 * the hover box for geometry calculation.
75 */
76 style?: CSSStyleDeclaration;
77 /**
78 * How to position the hover box if its edges extend beyond the view of the
79 * host element. Value 'sticky' positions the box at the (inner or outer)
80 * edge of the host element.
81 *
82 * #### Notes
83 * The default value for each edge is `'hidden-inside'` for left and top,
84 * and `hidden-outside` for right and bottom edges.
85 */
86 outOfViewDisplay?: {
87 top?: OutOfViewDisplay;
88 bottom?: OutOfViewDisplay;
89 left?: OutOfViewDisplay;
90 right?: OutOfViewDisplay;
91 };
92 /**
93 * Exact size of the hover box. Pass it for faster rendering (allowing the
94 * positioning algorithm to to place it immediately at requested position).
95 */
96 size?: {
97 width: number;
98 height: number;
99 };
100 }
101 /**
102 * An interface describing anchor coordinates.
103 */
104 interface IAnchor extends Pick<DOMRect, 'left' | 'right' | 'top' | 'bottom'> {
105 }
106 /**
107 * Set the visible dimensions of a hovering box anchored to an editor cursor.
108 *
109 * @param options - The hover box geometry calculation options.
110 */
111 function setGeometry(options: IOptions): void;
112}
113export {};