Mathlive Versions Save

A web component for easy math input

v0.94.7

11 months ago

0.94.7 (2023-06-08)

Improvements

  • #1989 Temporarily add back support for iOS versions older than 16.3.

0.94.6 (2023-05-25)

Bug Fixes

  • Only display seletion when the mathfield is focused
  • #1985 Add option for output format of getPromptValue()
  • #1985 Return Ascii Math output for prompts/placeholders.

Feature

  • Pressing the tab key will move to the "next group" in the mathfield, if possible.

0.94.5 (2023-05-24)

Bug Fix

  • The selection in read only mathfield was no longer visible.

0.94.3 (2023-05-22)

Improvements

  • The mathVirtualKeyboard.layouts property was a frozen array (an array that cannot be modified) but that wasn't clear. Now, a runtime error is produced if an attempt is made to modify the array. If using Typescript, a compile-time error is also generated.

Bug Fixes

  • #1979 Vectors were displayed with an offset
  • #1978 Pasting or inserting some content could result in a runtime error
  • #1978 Text content was not properly serialized in a \text{} command
  • #1682 Vectors (and other accents) are now spoken correctly
  • #1981 Adjusting the selection by moving backwards could result in a runtime error.
  • #1982 Improved resilience when a mathfield is in an embedded iframe which is not allowed to access the top window by cross-origin policy. In this situation the virtual keyboard is not available, but input via physical keyboard will work.

0.94.2 (2023-05-22)

Bug Fixes

  • #1976 Toggling the virtual keyboard several times would eventually not display the virtual keyboard.
  • Only apply smartFence in math mode (not in text or LaTeX mode).
  • #1975 When inserting a square root, do not insert an index by default

0.94.1 (2023-05-21)

Improvements

  • Use constructable stylesheets. This results in improved performance and a reduction of memory consuption by 2/3 in a page with 1,000 mathfields.
  • Improved MathML serialization (#1870, #1803, #1933, #1648, #737, #150, variants: blackboard, fraktur, bold, etc...).

Bug Fixes

  • #1963 Typing a "/" after a digit containing a french decimal (,) did not include the digits before the decimal.

v0.94.0

11 months ago

0.94.0 (2023-05-18)

New Features

  • Added support for \raise, \lower and \raisebox commands. Those commands were necessary to render some chemical bonds.
  • Pressing (, [ or { with a selection will enclose the selection with this delimiter.

Improvements

  • Improved parsing/serialization/rendering of content with a mix of text and math.
  • Various rendering improvements, mostly of edge cases.
  • Improved behavior of the Shift key in the math keyboard. Single-press the Shift key to set it temporarily, double-press it key to lock it (similar to CapsLock), triple-press it to unlock. This is similar behavior to the ones of mobile virtual keyboards.
  • #1647 Improved rendering of chemical bonds, e.g. \ce{ O\bond{~-}H}
  • Only on iOS, intercepts the cmd+XCV keyboard shortcut. On other platforms, use the standard cut/copy/paste commands, which do not require user permission.
  • The tooltips displayed by the \mathtooltip{} and \texttip{} commands are now displayed when used with a static formula.
  • Improvements to smart fence behavior, including better undoability.

Bug Fixes

  • Selection display was incorrect when the equation included a colored background.
  • Pasing text while in LaTeX mode now works.
  • Some of the arrows for mhchem have been renamed and are now displaying correctly
  • #1964 Prevent a runtime error when a mathfield is embedded in an iframe and MathLive is not loaded in the host document.
  • #1970 The environment popover was not always positioned correctly.
  • Correctly return unstyled LaTeX when requested (with format unstyled-latex). This strips any color/background-color/font sizing commands from the ouput.
  • The caret is no longer displayed twice when placed after \cos^2 (operators with a superscript).

New Contributors

Full Changelog: https://cortexjs.io/mathlive/changelog/

v0.63.0

3 years ago

New Features

  • #788 Added virtualKeyboardState property to indicate if the virtual keyboard is currently visible or hidden. The property can also be modified to show or hide the virtual keyboard.
  • In read-only mode, do not attempt to load the sounds and do not allow the virtual keyboard to be shown.
  • Export version (previously available as MathLive.version).
  • #199 Added infty and int inline shortcuts.

Bug Fixes

  • #708 Pressing on the bottom part of the virtual keyboard keycap did not trigger the key action.
  • The asset directory (fonts/sounds) was not properly located in some browsers when using a CDN to load Mathlive.
  • Correctly focus the mathfield when the virtual keyboard is invoked.

v0.62.0

3 years ago

0.62.0 (2021-04-23)

Improvements

  • #794 When a keycap on the virtual keyboard with associated alternate keys is long pressed, the other UI elements on the screen are ignored (a scrim element is inserted behind the panel to capture events).
  • On iPad OS prevent the document selection from being altered after long-pressing an alternate key in some cases.

Bug Fixes

  • A \chi13 (0.1em) gap between the nucleus and the above element was missing in OverUnder atoms (\overset, etc...).
  • On Safari iOS, correctly display the keyboard toggle glyph.
  • #907 When using renderMathInElement() or renderMathInDocument(), formulas containing styling information would get too aggressively coalesced, dropping some styling.
  • #910 Fixed an issue introduced in 0.61.0 where some content would not get rendered when calling renderMathInElement() or renderMathInDocument().

v0.58

3 years ago

0.58.0 (2020-10-11)

New Features

  • #225 Added onCommit listener to mf.options. This listener is invoked when the user presses Enter or Return key, or when the field loses focus and its value has changed since it acquired it. In addition, a change event is triggered when using a MathfieldElement. The event previously named change has been renamed to input. This mimics the behavior of <input> and <textarea> elements.

  • #225 Changed the keyboard shortcuts to add columns and rows:

    Shortcut Command
    ctrl/cmd + Return/Enter addRowAfter
    ctrl/cmd + shift + Return/Enter addRowBefore
    ctrl/cmd + ; addRowAfter
    ctrl/cmd + shift + ; addRowBefore
    ctrl/cmd + , addColumnAfter
    ctrl/cmd + shift + , addColumnBefore

    Note that Enter/Return no longer create a matrix/vector when inside a parenthesized expression. Use ctrl/cmd + Return/Enter instead.

  • Added a commit command to programmatically trigger the onCommit listener change event.

  • Added mount and unmount events to MathfieldElement

  • The $text() method, which is deprecated, was accidentally prematurely removed. It has been added back.

Bug Fixes

  • Inline shortcuts would not always be triggered correctly, for example x=sin -> x\sin instead of x=\sin
  • The text in tooltip was not vertically centered in narrow layouts (mobile devices)
  • #668 Extensible symbols, such as \xrightarrow were incorrectly treated as if they had an invisible boundary, resulting in the cursor being positioned incorrectly when navigating with the keyboard.

0.57.0 (2020-10-09)

Major New Feature

This release introduce two major new features which will require code changes. For now, the older API remains supported but it will be dropped in an upcoming release.

#665: Web Component

Support for MathfieldElement custom element/web component and <math-field> tag.

The makeMathField() method is still supported, but it will be removed in an upcoming version. You should transition to using <math-field> or MathfieldElement instead.

This transition require the following changes:

  1. Create mathfields using MathfieldElement or declaratively
// Before
let mf = MathLive.makeMathField(document.createElement('div'), {
    virtualKeyboardMode: 'manual',
});
mf.$latex('f(x) = \\sin x');
document.body.appendChild(mf.$el());

// After
let mfe = new MathfieldElement({
    virtualKeyboardMode: 'manual',
});
mfe.value = 'f(x) = \\sin x';
document.body.appendChild(mfe);

or:

<math-field virtual-keyboard-mode="manual">f(x) = \sin x</math-field>
  1. Use events instead of callbacks
    // Before
    mf.setConfig({ onContentDidChange: (mf) => {
        console.log(mf.$latex())
    });

    // After
    mfe.addEventListener('input', (ev) => {
        console.log(mfe.value);
    });

#667 Modernized Public API

Support for web component is an opportunity to revisit the MathLive public API and modernize it.

The goals are:

  • clarity. For example, the $latex() can be used to read or change the content of the mathfield.
  • expressiveness. For example, $selectedText() can return the value of the selection, but there is no way to inspect (or save/restore) the selection.
  • consistency with web platform APIs when applicable, otherwise following the monaco (VSCode editor) or CodeMirror conventions primarily. As part of this proposal, the APIs of TinyMCE, CKEditor and QuillJS were also considered. For example, the method equivalent to getConfig() is called getOptions() in most Javascript text editor libraries.

Mathfield methods

The following Mathfield methods have been renamed as indicated:

Before After
$setConfig() setOptions()
getConfig() getOptions() and getOption()
$text() getValue()
$latex() value, getValue() and setValue()
$insert() insert()
$hasFocus() hasFocus()
$focus() focus()
$blur() blur()
$selectedText() mf.getValue(mf.selection)
$selectionIsCollapsed() mf.selection[0].collapsed
$selectionDepth() mf.selection[0].depth
$selectionAtStart() mf.position === 0
$selectionAtEnd() mf.position === mf.lastPosition
$select() select()
$clearSelection() executeCommand('delete-previous-char')
$keystroke() executeCommand()
$typedText() executeCommand('typed-text')
$perform() executeCommand()
$revertToOriginalContent() n/a
$el() n/a
n/a selection
n/a position

The methods indicated with "n/a" in the After column have been dropped.

Only the new methods are available on MathfieldElement (i.e. when using web components). The Mathfield class retains both the old methods and the new ones to facilitate the transition, but the old ones will be dropped in an upcoming version.

There is also a new selection property on Mathfield and MathfieldElement which can be used to inspect and change the selection and a position property to inspect and change the insertion point (caret).

The getValue() method also now take an (optional) Range, which is the type of the selection property, to extract a fragment of the expression.

Default Exports

While default exports have the benefits of expediency, particularly when converting an existing code base to ES Modules, they are problematic for effective tree shaking. Therefore the default export will be eliminated.

This means that instead of:

import Mathlive from 'mathlive';
Mathlive.renderMathInDocument();

you will need to use:

import { renderMathInDocument } from 'mathlive';
renderMathInDocument();

The following functions have been renamed:

Before After
MathLive.latexToAST() Use MathJSON
MathLive.latexToMarkup() convertLatexToMarkup()
MathLive.latexToMathML() convertLatexToMathMl()
MathLive.latexToSpeakableText() convertLatexToSpeakableText()

New Features

  • #101: added getCaretPosition() and setCaretPosition()

Improvements

  • The Typescript types for Selector has been improved
  • The Typescript type for getOptions() (getConfig()) are more accurate
  • The "sqrt" inline shortcut now inserts an argument
  • Don't throw an error if the first argument of \enclose is empty
  • #591: add upward and downward hooks when navigating out of the mathfield (now also sent as a focus-out event)
  • Improved layout of the virtual keyboard on narrow mobile devices (fill the available width).

Bug Fixes

  • #198: typing backspace while typing inline shortcuts would prevent the shortcuts from being recognized
  • #573: brackets were not properly styled (i.e. color applied to them)
  • #543: spurious focus/blur events were dispatched if tabIndex was set to 0 on the mathfield and some area of the mathfield were clicked on. The issue was that with tabIndex="0" the mathfield frame would be focusable and when that happened the focus would correctly switch to the invisible <textarea> element which is normally focused to receive keyboard events, but this generated an incorrect blur event (for the container losing focus) and an incorrect focus event (for the <textarea> gaining focus)
  • #599: some characters, for example "ü", would not be correctly parsed or displayed. Note that technically, those characters are ignored by TeX, but it's a reasonable behavior nowadays to accept them as input.
  • #628: typing "e" repeatedly inside a matrix would corrupt the emited
  • #637: in Chrome, thin lines, such as fraction bars or square root lines would not display at some zoom levels
  • The locale was not properly taking into account when it was set manually
  • The config.strings property did not reflect the state of the localization strings
  • When configs was updated (e.g. new macros added), the content of the mathfield was not properly re-parsed and rendered
  • When making the virtual keyboard visible, the mathfield would not be focused
  • The virtual keyboard would not display correctly when the mathfield was inside a shadow DOM

Special Thanks

  • Thanks to @stefnotch for contributing several of the improvements in this release

v0.56.0

3 years ago

v0.55.0

3 years ago

v0.54.1

3 years ago

v0.54.0

3 years ago

v0.53.3

3 years ago