diff --git a/src/README.md b/src/README.md index 1010880..f03bbf7 100644 --- a/src/README.md +++ b/src/README.md @@ -116,6 +116,8 @@ See also the [tooltip example](../../examples/tooltip/). @hoverTooltip +@HoverTooltipSource + @hasHoverTooltips @closeHoverTooltips diff --git a/src/index.ts b/src/index.ts index 7b5898f..ab22629 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,7 +15,7 @@ export {Rect} from "./dom" export {layer, LayerMarker, RectangleMarker} from "./layer" export {MatchDecorator} from "./matchdecorator" export {rectangularSelection, crosshairCursor} from "./rectangular-selection" -export {showTooltip, Tooltip, TooltipView, tooltips, getTooltip, hoverTooltip, hasHoverTooltips, +export {showTooltip, Tooltip, TooltipView, tooltips, getTooltip, hoverTooltip, HoverTooltipSource, hasHoverTooltips, closeHoverTooltips, repositionTooltips} from "./tooltip" export {showPanel, PanelConstructor, Panel, getPanel, panels} from "./panel" export {lineNumbers, highlightActiveLineGutter, gutter, gutters, GutterMarker, diff --git a/src/tooltip.ts b/src/tooltip.ts index 948fd16..d10cb36 100644 --- a/src/tooltip.ts +++ b/src/tooltip.ts @@ -591,7 +591,9 @@ const showHoverTooltipHost = showTooltip.compute([showHoverTooltip], state => { const enum Hover { Time = 300, MaxDist = 6 } -type HoverSource = (view: EditorView, pos: number, side: -1 | 1) => Tooltip | readonly Tooltip[] | null | Promise +/// The type of function that can be used as a [hover tooltip +/// source](#view.hoverTooltip^source). +export type HoverTooltipSource = (view: EditorView, pos: number, side: -1 | 1) => Tooltip | readonly Tooltip[] | null | Promise class HoverPlugin { lastMove: {x: number, y: number, target: HTMLElement, time: number} @@ -600,7 +602,7 @@ class HoverPlugin { pending: {pos: number} | null = null constructor(readonly view: EditorView, - readonly source: HoverSource, + readonly source: HoverTooltipSource, readonly field: StateField, readonly setHover: StateEffectType, readonly hoverTime: number) { @@ -746,7 +748,7 @@ function isOverRange(view: EditorView, from: number, to: number, x: number, y: n /// container element. This allows multiple tooltips over the same /// range to be "merged" together without overlapping. export function hoverTooltip( - source: HoverSource, + source: HoverTooltipSource, options: { /// Controls whether a transaction hides the tooltip. The default /// is to not hide.