These hooks provide an opportunity to intercept or modify an action. When their return value is a boolean, it indicates if the default handling should proceed.

interface MathfieldHooks {
    onExport: ((from: Mathfield, latex: string, range: Range) => string);
    onInlineShortcut: ((sender: Mathfield, symbol: string) => string);
    onScrollIntoView: null | ((sender: Mathfield) => void);
}

Properties

onExport: ((from: Mathfield, latex: string, range: Range) => string)

This hooks is invoked when the user has requested to export the content of the mathfield, for example when pressing ctrl/command+C.

This hook should return as a string what should be exported.

The range argument indicates which portion of the mathfield should be exported. It is not always equal to the current selection, but it can be used to export a format other than LaTeX.

By default this is:

 return `\\begin{equation*}${latex}\\end{equation*}`;
onInlineShortcut: ((sender: Mathfield, symbol: string) => string)

A hook invoked when a string of characters that could be interpreted as shortcut has been typed.

If not a special shortcut, return the empty string "".

Use this handler to detect multi character symbols, and return them wrapped appropriately, for example \mathrm{${symbol}}.

onScrollIntoView: null | ((sender: Mathfield) => void)

A hook invoked when a scrolling the mathfield into view is necessary.

Use when scrolling the page would not solve the problem, e.g. when the mathfield is in another div that has scrollable content.