Skip to content

addHoverDescriptions

addHoverDescriptions(codeBlock, callback, options): void

Defined in: client/hover.ts:44

Utility that makes it easier to add hover descriptions to tokens.

PrismCodeBlock

Code block to add the functionality to.

(types, language, text, element) => (string | Node)[] | null | undefined

Function called when a token with only textual children is hovered.

The function gets called with the following arguments:

  • types: Array with the token’s type as the first element, followed by any alises.
  • language: The language at the token’s position.
  • text: The textContent of the token.
  • element: The <span> element of the hovered token.

Lastly, the function should return an array of children that get added to the tooltip. If null or undefined is returned, no tooltip is shown for the token.

HoverOptions = {}

Options for configuring the size and position of the tooltip.

void