Fork me on GitHub



INLINE_SHORTCUTS →[string]:stringstaticconstant

These shortcut strings are replaced with the corresponding LaTeX expression without requiring an escape sequence or command.

  • : [string]:string

KEYBOARD_SHORTCUTS →[string]:stringstaticconstant

The index of this array is a keystroke combination as returned by the key field of a JavaScript keyboard event as documented here: except for:

  • EscapeEsc
  • LeftArrow... → Left/Right/Up/Down
  • DeleteDel
  • EscapeEsc
  • ' ' → Spacebar

The modifiers are specified before the main key, in the following order:

  1. Ctrl
  2. Meta: Command key on Mac OS. On Windows this is the Windows key, but the system intercepts those key combinations so they are never received
  3. Alt: Option key on Mac OS
  4. Shift

The keys can be preceded by a context to restrict when the shortcut is applicable. For example, "math:Ctrl-KeyA" will restrict this shortcut to only apply in the "math" context (parseMode). Other valid context include "text" and "command".

The value of the entries represent the command to perform. This can be either a single selector, or an array of a selector followed by its arguments. Selectors uses the following naming conventions:

  • a 'char' is a math atom (a letter, digit, symbol or compound atom)
  • a 'word' is a sequence of math atoms of the same type
  • a 'group' is a sequence of sibling atoms, for example a numerator or a superscript
  • the 'MathField' is the entire expression being edited
  • a 'placeholder' is either an actual placeholder atom or an empty child list, for example an empty numerator
  • 'move' changes the position of the insertion point (and collapses the selection range if necessary)
  • 'extend' keeps the anchor of the selection, but moves the focus (extends, or shrinks, the range of selected items)
  • : [string]:string

REVERSE_KEYBOARD_SHORTCUTS →[string]:stringstaticconstant

Most commands can be associated to their keyboard shortcuts from the KEYBOARD_SHORTCUTS table above, for example 'speakSelection' -> 'Ctrl-KeyR' However, those that contain complex commands are more ambiguous. For example, '\sqrt' -> 'math:Alt-KeyV'. This table provides the reverse mapping for those more complex commands. It is used when displaying keyboard shortcuts for specific commands in the popover.

  • : [string]:string


forString(mode: string, context: string, s: string, config: object): stringprivatestatic

This function is used to resolve inline shortcuts.

mode : string
context : string

atoms preceding the candidate, potentially used to reduce which shortcuts are applicable. If 'null', no restrictions are applied.

s : string

candidate inline shortcuts (e.g. 'pi')

config : object
: string   
  • A replacement string matching the shortcut (e.g. '\pi')

platform(p: string): stringprivatestatic

Return p, the platform name if p is the current platform, otherwise return !p. For example, when running on Windows, platform('mac') returns '!mac'. The valid values for p are:

  • 'mac'
  • 'win'
  • 'android'
  • 'ios'
  • 'chromeos'
  • 'other' (Linux, etc...)
p : string

The platform to test against.

: string   

if we are running on the candidate platform, return it. Otherwise, return "!" + candidate.

selectorForKeystroke(mode: string, keystroke: string): stringprivatestatic

Return the selector matching the keystroke.

mode : string
keystroke : string
: string   

stringify(shortcuts: [string]:string, joinnullable: string)privatestatic

Return a human readable representation of an array of shortcut strings

shortcuts : [string]:string
join : string nullable

optional, string in between each shortcut representation

startsWithString(s: string, config: object): string[]inner

Return an array of potential shortcuts

s : string
config : object
: string[]   

validateShortcut(mode: string, siblings: object[], shortcut: string)inner

mode : string
siblings : object[]

atoms preceding this potential shortcut

shortcut : string