/* 0.112.0 */ import type { Selector } from './commands'; import type { LatexSyntaxError, MacroDictionary, ParseMode, Registers, Style } from './core-types'; import type { InsertOptions, OutputFormat, Offset, Range, Selection, Mathfield, ElementInfo } from './mathfield'; import type { InlineShortcutDefinitions, Keybinding, MathfieldOptions } from './options'; import type { MenuItem } from './ui-menu-types'; import type { ComputeEngine } from '@cortex-js/compute-engine'; import { KeyboardModifiers } from './ui-events-types'; import { SeparatorCharacter } from '../tera-research/separator'; /** @category MathJSON */ export declare type Expression = number | string | { [key: string]: any; } | [Expression, ...Expression[]]; /** * ## Event re-targeting * Some events bubble up through the DOM tree, so that they are detectable by * any element on the page. * * Bubbling events fired from within shadow DOM are re-targeted so that, to any * listener external to your component, they appear to come from your * component itself. * ## Custom Event Bubbling * By default, a bubbling custom event fired inside shadow DOM will stop * bubbling when it reaches the shadow root. * To make a custom event pass through shadow DOM boundaries, you must set * both the `composed` and `bubbles` flags to true. * The `move-out` event signals that the user pressed an **arrow** key or * **tab** key but there was no navigation possible inside the mathfield. * * This event provides an opportunity to handle this situation, for example * by focusing an element adjacent to the mathfield. * * If the event is canceled (i.e. `evt.preventDefault()` is called inside your * event handler), the default behavior is to play a "plonk" sound. * * @category Web Component */ export type MoveOutEvent = { direction: 'forward' | 'backward' | 'upward' | 'downward'; }; /** * - `"auto"`: the virtual keyboard is triggered when a * mathfield is focused on a touch capable device. * - `"manual"`: the virtual keyboard is not triggered automatically * - `"sandboxed"`: the virtual keyboard is displayed in the current browsing * context (iframe) if it has a defined container or is the top-level browsing * context. * * @category Virtual Keyboard */ export type VirtualKeyboardPolicy = 'auto' | 'manual' | 'sandboxed'; declare global { /** * Map the custom event names to types * @internal */ interface HTMLElementEventMap { 'mode-change': CustomEvent; 'mount': Event; 'unmount': Event; 'move-out': CustomEvent; 'read-aloud-status-change': Event; 'selection-change': Event; 'undo-state-change': CustomEvent; 'before-virtual-keyboard-toggle': Event; 'virtual-keyboard-toggle': Event; } } /** * These attributes of the `` element correspond to the * [MathfieldOptions] properties. * * @category Web Component */ export interface MathfieldElementAttributes { [key: string]: unknown; 'default-mode': string; 'letter-shape-style': string; 'min-font-scale': number; 'max-matrix-cols': number; 'popover-policy': string; /** * The LaTeX string to insert when the spacebar is pressed (on the physical or * virtual keyboard). Empty by default. Use `\;` for a thick space, `\:` for * a medium space, `\,` for a thin space. */ 'math-mode-space': string; /** When true, the user cannot edit the mathfield. */ 'read-only': boolean; 'remove-extraneous-parentheses': boolean; /** * When `on` and an open fence is entered via `typedText()` it will * generate a contextually appropriate markup, for example using * `\left...\right` if applicable. * * When `off`, the literal value of the character will be inserted instead. */ 'smart-fence': string; /** * When `on`, during text input the field will switch automatically between * 'math' and 'text' mode depending on what is typed and the context of the * formula. If necessary, what was previously typed will be 'fixed' to * account for the new info. * * For example, when typing "if x >0": * * | Type | Interpretation | * |---:|:---| * | "i" | math mode, imaginary unit | * | "if" | text mode, english word "if" | * | "if x" | all in text mode, maybe the next word is xylophone? | * | "if x >" | "if" stays in text mode, but now "x >" is in math mode | * | "if x > 0" | "if" in text mode, "x > 0" in math mode | * * Smart Mode is `off` by default. * * Manually switching mode (by typing `alt/option+=`) will temporarily turn * off smart mode. * * * **Examples** * * - slope = rise/run * - If x > 0, then f(x) = sin(x) * - x^2 + sin (x) when x > 0 * - When x<0, x^{2n+1}<0 * - Graph x^2 -x+3 =0 for 0<=x<=5 * - Divide by x-3 and then add x^2-1 to both sides * - Given g(x) = 4x – 3, when does g(x)=0? * - Let D be the set {(x,y)|0<=x<=1 and 0<=y<=x} * - \int\_{the unit square} f(x,y) dx dy * - For all n in NN * */ 'smart-mode': string; /** * When `on`, when a digit is entered in an empty superscript, the cursor * leaps automatically out of the superscript. This makes entry of common * polynomials easier and faster. If entering other characters (for example * "n+1") the navigation out of the superscript must be done manually (by * using the cursor keys or the spacebar to leap to the next insertion * point). * * When `off`, the navigation out of the superscript must always be done * manually. * */ 'smart-superscript': string; /** * Maximum time, in milliseconds, between consecutive characters for them to be * considered part of the same shortcut sequence. * * A value of 0 is the same as infinity: any consecutive character will be * candidate for an inline shortcut, regardless of the interval between this * character and the previous one. * * A value of 750 will indicate that the maximum interval between two * characters to be considered part of the same inline shortcut sequence is * 3/4 of a second. * * This is useful to enter "+-" as a sequence of two characters, while also * supporting the "±" shortcut with the same sequence. * * The first result can be entered by pausing slightly between the first and * second character if this option is set to a value of 250 or so. * * Note that some operations, such as clicking to change the selection, or * losing the focus on the mathfield, will automatically timeout the * shortcuts. */ 'inline-shortcut-timeout': string; 'script-depth': string; /** When the mathfield is empty, display this placeholder LaTeX string * instead */ 'placeholder': string; /** * - `"auto"`: the virtual keyboard is triggered when a * mathfield is focused on a touch capable device. * - `"manual"`: the virtual keyboard is not triggered automatically * - `"sandboxed"`: the virtual keyboard is displayed in the current browsing * context (iframe) if it has a defined container or is the top-level browsing * context. * */ 'math-virtual-keyboard-policy': VirtualKeyboardPolicy; /** * Specify the `targetOrigin` parameter for * [postMessage](https://developer.mozilla.org/en/docs/Web/API/Window/postMessage) * to send control messages from child to parent frame to remote control * of mathfield component. * * **Default**: `window.origin` */ 'virtual-keyboard-target-origin': string; } export type InsertStyleHook = (sender: Mathfield, at: Offset, info: { before: Offset; after: Offset; }) => Readonly