mathlive

A web component for easy math input

MIT License

Downloads
292.5K
Stars
1.6K
Committers
80

Bot releases are visible (Hide)

mathlive - v0.100.0

Published by arnog 4 months ago

0.100.0 2024-06-12

Bug Fixes

  • #2396 Pressing the arrow keys in the virtual keyboard would not move the
    selection in the mathfield and display a runtime error in the console.

  • #2395 Added a dispatchEvent command which can be attached to a
    custom keycap.

  • #2392 Pressing the backspace key after typing several digits would
    delete all the digits.

    Its first argument is the name of the dispatched event, and the second
    argument is an object with the detail property, which is the data
    associated with the event.

      { 
        label: "✨",
        command: "displatchEvent('customEvent', {detail: 'some data'})"
      }
    

    To handle the event, add an event listener to the mathfield element:

    mf.addEventListener('customEvent', (ev) => {
      console.log(ev.detail);
    });
    

0.99.0 2024-06-10

Breaking Changes

  • The mf.offsetFromPoint() method has been renamed mf.getOffsetFromPoint()

  • The mf.scriptDepth() and mf.hitboxFromOffset() methodds have been
    replaced with mf.getElementInfo().

    The getElementInfo() method provides more information including any id
    that may have been applied with \htmlId{}.

    It is useful from within a click handler to get more information about the
    element that was clicked, e.g.

      mf.getElementInfo(mf.getOffsetFromPoint(ev.clientX, ev.clientY))
    

    The info returned is an object with the following properties:

    export type ElementInfo = {
      /** The depth in the expression tree. 0 for top-level elements */
      depth?: number;
    
      /** The bounding box of the element */
      bounds?: DOMRect;
    
      /** id associated with this element or its ancestor, set with `\htmlId` or 
         `\cssId`   
      */
      id?: string;
    
      /** HTML attributes associated with element or its ancestores, set with
       * `\htmlData`
       */
      data?: Record<string, string | undefined>;
    
      /** The mode (math, text or LaTeX) */
      mode?: ParseMode;
    
      /** A LaTeX representation of the element */
      latex?: string;
    
      /** The style (color, weight, variant, etc...) of this element. */
      style?: Style;
    };
    

Bold

The way bold is handled in LaTeX is particularly confusing, reflecting
limitations of the text rendering technology of the time.

Various attempts have been made over the years to improve the rendering of
bold, but this has resulted in inconsistent behavior. Furthermore, various
implementations of LaTeX and LaTeX-like systems have implemented bold in
different ways.

This release introduces a more consistent and intuitive handling of bold,
although it may result in different rendering of some formulas compared to
some implementations of LaTeX.

The original bold command in LaTeX is \mathbf. This command renders its
argument using a bold variant of the current font. However, only letters and
numbers can be rendered by this command. It does not affect symbols, operators,
or greek characters.

For example, \mathbf{a+b} will render as 𝐚+𝐛, with the a and b in bold,
but the + in normal weight. Characters rendered by \mathbf are rendered
upright, even if they would have been rendered as italic otherwise.

The \boldsymbol command is an alternative to \mathbf that affects more
characters, including Greek letters and symbols. It does not affect
the style of the characters, so they remain italic if they were italic before.
However, the inter-character spacing and italic correction may not be rendered correctly.

The \bm command from the bm package is a more modern alternative that
affects even more characters. It also preserves the style of the characters,
so they remain italic if they were italic before. The inter-character spacing
and italic correction are handled correctly.

The \bm command is recommended over \boldsymbol and \mathbf. However,
it is not part of the standard LaTeX distribution, so it may not always be available.

When serializing to LaTeX, MathLive will now use \mathbf when possible, and
fall back to \bm when not. This should result in more consistent rendering
of bold text.

When parsing, MathLive will interpret both \mathbf, \boldsymbol and \bm as
bold.

The bold style is now consistently inherited by sub-expressions.

Similarly, when applying a bold style using mf.applyStyle({weight: "bold"}),
the bold attribute is applied to the entire selection, not just the letters
and numbers.

Mode Switching

  • #2375 The switch-mode command has two optionals arguments, a prefix
    and suffix. The prefix is inserted before the mode switch, and the suffix
    after. The command was behaving incorrectly. It now behaves as expected.
  • It is now possible to roundtrip between math and text mode. For example,
    selecting a fraction \frac{a}{b} and pressing alt+shift+T will convert the
    selection to (a)/(b). Pressing alt+shift+T again will convert it back to
    \frac{a}{b}.
  • When in LaTeX mode, changing the selection would sometimes unexpectedly exit
    LaTeX mode, for example after the Select All command. This has been fixed.

New Features

  • \href

    The \href{url}{content} command, a MathJax extension that allows a link
    to be associated with some content, is now supported.

    Clicking on the content will open the link. By default, the link is opened
    in a new window, and only links with a HTTP, HTTPS or FILE protocol are
    allowed. This can be controlled by the new MathfieldElement.openUrl
    property. This property is a function with a single argument, the URL to
    be opened, that is called when the content of the \href command is clicked on.

  • Tooltip appearance

    Added CSS variables to control the appearance of the toolip displayed with
    \mathtip and \texttip:

    • --tooltip-border
    • --tooltip-color
    • --tooltip-background-color
    • --tooltip-box-shadow
    • --tooltip-border-radius.
  • The maxMatrixCols property has been added that specifies the maximum number
    of columns that a matrix may have. The default value is 10, which follows the
    default value from the amsmath package. The property applies to all of
    the matrix environments (matrix, pmatrix, bmatrix, etc.). This property is
    also accessible via the max-matrix-cols attribute.

  • The virtual keyboard now supports variants for shifted-keys. This includes
    support for Swedish specific characters such as å, ä, and ö and their
    uppercase variants.

  • Accept "true" and "false" as values for on/off attributes in the
    <math-field> element, for example <math-field smart-fence="true">.

  • Added a target property (a MathfieldElement) to the onMenuSelect
    arguments.

  • #2337 Added an option MathfieldElement.restoreFocusWhenDocumentFocused
    to control whether a mathfield that was previously focused regains focus
    when the tab or window regains focus. This is true by default and matches
    the previous behavior, and the behavior of the <textarea> element.

  • An alternate syntax for selectors with arguments. Selectors are used for
    example to associate actions with a keycap, such as switchKeyboardLayer.
    The previous syntax was command: ["switchKeyboardLayer", "alt-layer"],
    the new syntax is command: 'switchKeyboardLayer("alt-layer")'. This is more
    concise and easier to read.

Issues Resolved

  • #2387 When using a macro, the spacing around the macro was incorrect in
    some cases.
  • #2370 The order of the keydown and input event is now consistent
    with the <textarea> element.
  • #2369 After typing a shortcut, using the backspace key could result
    in unexpected behavior. Now, pressing the backspace key after a shortcut
    has been typed will undo the conversion of the shortcut.
  • #2380 In some cases, when using the menu, some spurious focus/blur events
    would be dispatched.
  • #2384 When using repeating decimals after a comma (i.e. 123{,}4(1)),
    do not use a \left...\right command in order to get the proper spacing.
  • #2349 The positioning of subscripts for extensible symbols, such as \int
    was incorrect.
  • #2326 The Cut and Copy commands in the context menu are now working
    correctly in Safari.
  • #2309 When using styled text (e.g. \textit{}), the content could
    sometimes be serialized with an unnecessary \text{} command, i.e.
    \text{\textit{...}}.
  • #2376 When smart-fence was off, the { and } keys would not insert
    braces.
  • #2273 Using one of the Chinese locales would result in a runtime error.
  • #2355 When pressing the down arrow key in \sqrt[#?]{1} from the #?
    position, a runtime exception would occur.
  • #2298 When using screen readers, pressing the spacebar would not always
    correctly focus the mathfield.
  • #2297 In some cases, when using touch input, the previously selected item
    in a context menu would appear to be selected.
  • #2289 When changing the value of the mathfield, the selection is now
    preserved. In addition, when using a controlled component with React an
    unnecessary update is avoided.
  • #2282 Don't display selection when the mathfield is not focused
  • #2280 Handle better very deeply nested expressions
  • #2261 When a style was applied to an empty range, the style was ignored.
  • #2208 When setting a variant style (i.e. blackboard, fraktur, etc...) the
    style is no longer adopted by subsequent characters.
  • #2104, #2260 When replacing the selection by typing, the new content would not
    always be correctly styled. The content now inherits the style of the
    selection, or the style of the insertion point if the selection is collapsed.
  • Better handle the case where the mathlive library gets loaded before the DOM
    is constructed.
  • On Safari, the Insert Matrix submenu was displayed incorrectly.
  • When the mathfield is an iframe, the before-virtual-keyboard-toggle and
    virtual-keyboard-toggle events are now dispatched on the
    window.mathVirtualKeyboard object of the iframe. This can be used to detect
    a request (and prevent) for the virtual keyboard to be displayed.
  • If the unknown in an expression was a complex identifier, such as \mathcal{C}
    it would not be displayed correctly in the "Solve for" menu.
  • The \mathrlap command was incorrectly rendering like \mathllap.

0.98.6 2024-01-27

New Features

  • Added StaticRenderOptions.TeX.className to specify that an element with the
    specified class name should be rendered as a LaTeX formula.
  • #2273 Added a --keycap-width CSS variable to specify the width of a
    keycap in a virtual-keyboard. By default, if the CSS variable is not
    specified, the width of the keycap is calculated based on the width of the
    parent container. However, this requires browser that support the cq CSS
    unit. If the browser does not support the cq CSS unit, this CSS variable can
    be used to specify the width of the keycap. (See #2028, #2133)
  • #2255 Support for gather* environment
  • #2242 A virtual keyboard keycap can now include a tooltip for its shifted
    variant.

Issues Resolved

  • When using some APIs such as renderToMarkup() or renderToMathML() in a
    server-side environment, a runtime error would occur.
  • When tabbing in a mathfield with multiple prompts, tab out of the mathfield
    when the last or first prompt is reached.
  • **#2243##, **#2245** Unicode characters such as ² or are now
    interpreted as their LaTeX equivalent only when in math mode.
  • #2237 The command \iff now renders correctly
  • #2246 Changing the mf.value property would not always update the value
    of the mathfield.
  • #2244 Worked around an issue in Safari on iOS where doing a double-tap on
    the virtual keyboard would result in the mathfield losing focus and the
    virtualy keyboard closing.
  • #2252 At some viewport sizes, the integral sign in the symbols virtual
    keyboard would be clipped.
  • #2235 Improved serialization to ASCIIMath.
  • Avoid conflicts with some class names when rendering static math.
  • When using renderMathToElement() or renderMathInDocument(), coalesce
    adjacent text nodes.
  • Correctly parse the \cfrac optional alignment argument
  • The commands \bf, \bfseries, \mdseries, \upshape, \itshape,
    \slshape, \scshape, \rmfamily, \sffamily, \ttfamily are now
    interpreted correctly.
  • The command \operatorname is now spoken correctly
  • #2152 On Safari, fill-in-the-blank prompts containing a fraction were
    rendered incorrectly.

0.98.5 2023-12-27

Issues Resolved

  • When a font size command is inside a \left...\right command, apply the font
    size to the content of the command. As a result
    \frac34 + \left( \scriptstyle \frac12 \right) will now render as expected.

  • #2214 When using Linux or Windows with a German keyboard layout, typing
    the ^ key will now switch to superscript.

  • #2214 When typing Unicode characters such as ² or , correctly
    interpret them as their LaTeX equivalent. This also affects parsing of the
    value property.

  • #2000, #2063 A mathfield with multiple lines now generate correct
    LaTeX using the \displaylines command.

  • When a superscript or subscript is attached to a function, correctly position
    a following \left...\right command closer to the function.

  • When typing a superscript after f, g or some other function, correctly
    interpret the superscript as an exponent, not as a function argument.

  • #787, #1869 The f, g and h symbols are no longer hardcoded as
    symbols representing functions.

    Whether a symbol is considered a function affects the layout of a formula,
    specifically the amount of space between the symbol and a subsequent delimiter
    such as a parenthesis.

    Now whether a symbol should be treated as a function is determined by the
    MathfieldElement.isFunction hook.

    By the default, this hook uses the MathfieldElement.computeEngine to
    determine if the domain of a symbol is a function.

    This can be customized by setting the isFunction property of the mathfield
    or by declaring a symbol as a function using the declare() method of the
    compute engine. For example:

    MathfieldElement.computeEngine.declare("f", "Functions");
    

    In addition, a new isImplicitFunction hook has been added which can be used
    to indicate which symbols or commands are expected to be followed by an
    implicit argument. For example, the \sin function can be followed by an
    implicit argument without parentheses, as in \sin \frac{\pi}{2}. This
    affects the editing behavior when typing a / after the function. If an
    implicit function, the / will be interpreted as an argument to the function,
    otherwise it will be interpreted as a fraction with the function as the
    numerator.

  • The "phi" keycap in the virtual keyboard was incorrectly displaying the
    \varphi symbol. It now displays the \phi symbol.

  • #2227 Updating the content of the mathfield with mf.innerText will now
    correctly update the value of the mathfield.

  • #2225 For consistency with <textarea>, when setting the value change the
    selection to be at the end of the mathfield.

0.98.3 2023-12-07

Improvements

  • Improved contrast calculation for the checkmarks over color swatches, now
    using APCA.

  • In some situations, the virtual keyboard would not be displayed when the
    mathfield was focused and the mathVirtualKeyboardPolicy was set to "auto".

0.98.2 2023-12-06

Improvements

  • In some rare cases, the menu was not positioned correctly or would not display
    at all.

  • When dynamically changing the layout of the mathfield, for example when using
    a font-size attribute based on viewport units, correctly redraw the selection

  • Selection while dragging would stop after a few milliseconds

  • The "contains highlight" indicator is no longer displayed when the mathfield
    is not focused or when the indicator is outside of a prompt.

  • #2194 Ignore long press events when the pointer is a mouse.

Issues Resolved

  • #2195 If the mathfield had a variable width the selection would not be
    displayed correctly.

  • #2190 Under some circumstances, commands selected from the menu could be
    executed twice.

0.98.1 2023-12-05

New Features

  • Added mf.showMenu() method to programmatically show the context menu.

Issues Resolved

  • Correctly position the menu when the document has been scrolled.

  • When serializing, do not generate a \text command around a \texttt
    command.

Improvements

  • Keyboard navigate submenus with a grid layout

0.98.0 2023-12-03

Breaking Changes

  • The mf.setPromptContent() method has been renamed to mf.setPromptValue()
    for consistency with the mf.getPromptValue() method.

  • The mf.stripPromptContent() method has been removed. Its functionality can
    be achieved with:

const prompts = mf.getPrompts();
const values = prompts.map(id => mf.getPromptValue(id));
prompts.forEach(id => mf.setPromptValue(id, ""));

Improvements

  • A new mf.getPromptRange() method returns the selection range of a prompt.
    This can be used for example to focus a mathfield and select a specific
    prompt:
mf.focus();
mf.selection = mf.getPromptRange(id);
  • The Color, Background Color and Variant menus correctly toggle the colors and
    variant, and reflect their state with a checkmark or mixedmark.

  • Setting the mf.menuItems property before the mathfield is inserted in the
    DOM will now correctly update the menu items.

  • Correctly display tooltips in the menu when invoked via the menu icon.

  • Localized menu items in the context menu.

New Features

  • #348 Added a placeholder attribute, similar to the placeholder
    attribute of a <textarea> element. This specifies a short hint as a LaTeX
    string that describes the expected value of the mathfield. When the mathfield
    is empty, the placeholder text is displayed. The placeholder text can be
    styled with the math-field::part(placeholder) CSS selector.

  • #2162 Added a "latex-without-placeholders" format to the getValue()
    method. This format is similar to the "latex" format, but does not include
    the placeholders (for "fill-in-the-blanks").

Issues Resolved

  • #2169 Changing the selection programatically will now correctly update the
    mathfield.

  • #2189 If the decimal separator is set to ,, the virtual keyboard will
    now correctly display the decimal separator as a comma.

  • #2139 On some keyboard layouts, ALT+/ would insert a
    \/ command, which is not standard. Now, the simple / is inserted.

0.97.4 2023-11-29

Issues Resolved

  • When a global .row class was defined, it would be applied to the virtual
    keyboard rows, resulting in incorrect layout.

Improvements

  • Added mf.queryStyle() method to query the style of a selection or the
    current style if no selection.

0.97.3 2023-11-28

Improvements

  • The mode-change event is now dispatched more consistently when the mode
    changes.

  • When the mathfield loses focus, if some of the content is in LaTeX mode, it
    remains in LaTeX mode. Previously, it would switch to math mode when losing
    focus.

  • Changing the user-select CSS property before inserting the mathfield in the
    DOM would not always be respected.

  • Use the DOM Popover API when available, which should ensure menus are
    displayed on top of other elements more consistently.

  • Added support for accented characters in the virtual keyboard (press and hold
    a vowel on an alphabetic keyboard to get accented variants), including a
    modified AZERTY layout (SHIFT+digits to get common accented
    characters).

  • Improved rendering of the menu for CJK and LTR languages.

Issues Resolved

  • If there were multiple mathfield elements on the page, only the last one would
    display tooltips.

  • #2184 Pressing the TAB key when in a prompt (fill-in-the-blank)
    would not move to the next prompt

  • #2183 The MathML serialization of factorial was incorrect.

  • #2181 The MathML serialization of limits was incorrect.

0.97.2 2023-11-21

Issues Resolved

  • Keybindings for German Linux keyboard layout were not working correctly.

0.97.1 2023-11-20

Issues Resolved

  • #2180 Allow the context menu to get turned off by setting
    mf.menuItems = []

  • Fixed a layout issue with the positioning of the context menu in some cases.

  • Improved dark mode appearance of context menu

0.97.0 2023-11-20

New Features

  • Context Menu Right-clicking on a mathfield or clicking the menu icon next
    to the virtual keyboard icon will bring up a context menu.

    The keyboard shortcut ALT+SPACE will also bring up the
    context menu. This keyboard shortcut previously toggled the virtual keyboard.
    This keyboard shortcut to toggle the virtual keyboard is now
    ALT+SHIFT+SPACE.

    The menu includes commands to:

    • insert and edit matrixes
    • evaluate, simplify and solve equations
    • change the variant of a symbol (blackboard, fraktur, etc...)
    • change the style (italic, bold, etc...) of the selection
    • change the color and background color
    • insert text
    • copy LaTeX, MathML or MathASCII to the clipboard
    • toggle the virtual keyboard

    The content of the menu may change in future versions, and feedback is
    welcome.

    The menu can be customized by setting the mf.menuItems property of the
    mathfield. The value of this property is an array of menu items. See
    the documentation for details.

Improvements

  • The tooltip above the virtual keyboard toggle (and the menu glyph) now only
    appears after a delay.

Issues Resolved

  • The expression \pmod5 is now correctly parsed as \pmod{5}. Macros that
    used an argument that was not a literal group were not parsed correctly.

0.96.2 2023-11-16

Issues Resolved

  • The vertical alignment of formulas containing some fractions was incorrect in
    some cases.
  • #2168 Changing the MathfieldELement.locale or MathfieldElement.strings
    would not affect existing mathfields.
  • Incorrectly accessing static properties (for example using mf.locale instead
    of MathfieldElement.locale) will now throw an error.
  • #2160 The keycap tooltips were not displayed.
  • #2144 When smartFence was on, an inline shortcut that conflicted with a
    delimiter was ignored.

Improvements

  • #2141: Added St Mary's Road symbols for theoretical computer science,
    including \mapsfrom.
  • #2158 Support the German keyboard layout on Linux.
  • #2102 The mathfield element now respects the user-select CSS property.
    If it is set to none, the mathfield will not be selectable.

0.96.1 2023-11-15

Improvements

  • Simplified the syntax to modify registers. Use
    mf.registers.arraystretch = 1.5 instead of mf.registers = {...mf.registers,
    arraystretch: 1.5}`
  • Allow changing registers using \renewcommand, for example
    \renewcommand{\arraystretch}{1.5}
  • Added keycap shortcuts [up] and [down] to move the selection up or down in
    a matrix.
  • Display the environment popover when the selection is inside a matrix, even
    when the virtual keyboard is not visible.

Issues Resolved

  • #2159 Runtime error in sandboxed mode when in an iframe from different
    origin
  • #2175 Addressed some rendering issues with Safar where a fraction inside a
    \left...\right was vertically offset.
  • #2176 Using the [hide-keyboard] virtual keycap would cause a runtime
    error.
  • #2161 When the virtual keyboard is hidden, a geometrychange event is
    dispatched.

0.96.0 2023-11-14

Breaking Changes

  • The function serializeMathJsonToLatex() has been renamed to
    convertMathJsonToLatex() for consistency.

Issues Resolved

  • A closing parenthesis following a function application would be ignored, i.e.
    (f(x)) would be parsed as (f(x).
  • #2116 Pressing the "/" key after an expression ending with a superscript
    would not recognize the left argument as a numerator.
  • #2124 In text mode, some characters were incorrectly interpreted as a math
    command, for example ( was interpreted as \lparen`. This could cause some
    interoperability issues.
  • #2110 If using the keyboard to enter several macros mapping to an
    \operatorname command, some of the commands could fail to render. For
    example, typing "1mm + 2mm" in a mathfield would result in "1 + 2mm" to be
    displayed.
  • When inserting an mchem atom, preserve the verbatimLatex associated with the
    atom, so that the value property of the atom is correctly serialized.
  • When invoking the moveToMathfieldEnd command, the selection was not changed
    if it was not collapsed and already at the end of the mathfield. Similarly for
    moveToMathfieldStart.

Improvements

  • Added support for additional commands from the mathtools, actuarialangle,
    colonequals, statmath and amsopn packages
  • Added support for longdiv enclosure (\mathenclose{longdiv}{...})
  • The decimal separator key (.) in the virtual keyboard was displayed as a
    blank key.
  • #2109 In the virtual keyboard, some placeholders could be hard to see when
    a keycap was in a pressed state.
  • #2105 The keycap shift + in the numeric keyboard was inserting a sum
    with limits contrary to what the keycap label indicated.
  • In the alphabetic virtual keyboard, the , key now produces a semicolon when
    shifted and has a variant panel with additional punctuation.
  • Improved virtual keyboard for integrals with more explicit template
  • When removing the limit of an integral or a sum, do not delete the operator
    itself.
  • #2122 On the Virtual Keyboard, the multiplication key now produces \cdot
    instead of \times. Use shift to produce \times.
  • Improved serialization to ASCIIMath and MathML (#2130 and others)
  • #2121 For ASCIIMath and MathML serialization, including phantom closing
    delimiter in the output.
  • Pressing the Action keycap on the virtual keyboard with the shift key pressed
    now inserts a new line (similar to what shift+enter does on a physical
    keyboard).
  • Render \displaystyle and \textstyle to MathML
  • Avoid runtime error if the mathfield gets deleted during a selection change
    event.

0.95.5 2023-08-18

Issues Resolved

  • #2091 The variant panel for the 7 key was the variant panel for 4.
  • #2093 Inline shortcuts can be corrected with backspace, i.e. typing
    sen[backspace][backspace]in will be corrected to \\sin.
  • #2018 Some VK toolbar items could be offset by a few pixels on some mobile
    devices
  • The caret was not visible when placed after an \operator*{} command
  • The \class{}{} command in a mathfield was not working correctly.

Improvements

  • #2052 When double-clicking then dragging, the selection is now extended to
    the nearest boundary. This applies to math, text and LaTeX zones.
  • Added prompt CSS part to the mathfield element. This allows styling of
    prompts (placeholders) in a fill-in-the-blank mathfield.
  • Added w40 keycap class (4-wide)
  • When using renderMathInElement() preserve the LaTeX as a data- attribute
    on the element.
  • Added speakable text for \imaginaryI, \imaginaryJ, \ne and \neq
  • Added ARIA label to keyboard toggle glyph
  • More robust check for PointerEvent support
  • Throw an error if attempting to access mf.mathVirtualKeyboard. The virtual
    keyboard is now a singleton, accessible as window.mathVirtualKeyboard.
  • When a command attribute is associated with a keycap, a
    math-virtual-keyboard-command event is dispatched when the keycap is
    pressed.

0.95.4 2023-08-11

Issues Resolved

  • #2090 A runtime error could occur when adding a superscript inside a
    square root
  • #2068 Use a more compact keyboard layout for phones in landscape mode.

Improvements

  • #2089 Added x^{#?} in the virtual keyboard variant panel for x
  • #2082 The shortcut for \int was triggered with sint. Note that in case
    of similar conflicts, pressing the spacebar will prevent the shorcuts from
    taking effect, i.e. "sin t".

0.95.2 2023-08-09

Improvements

  • Added if-math-mode and if-text-mode classes to conditionally show virtual
    keyboard keys.
  • #2086 When navigation a root with an index, the index is now navigater
    first.

0.95.1 2023-07-25

Improvements

Issues Resolved

  • #1995 When right clicking to bring up the variant panel in the virtual
    keyboard, in some situations the virtual keyboard would lock up.
  • #2047 Use \exp instead of \mathrm{exp} in the virtual keyboard
  • #2067 When setting up the virtual keyboard policy to "sandboxed" in a
    cross domain iframe, a runtime error would occur.

0.95.0 2023-07-04

Improvements

  • Improved behavior when pressing the tab key
  • #2015 New environmentPopoverPolicy option. Set to:
    • "auto" to show environment popover when inside a tabular environment and
      the virtual keyboard is visible (current behavior)
    • "on" to show it when in a tabular environment
    • "off" to never show it

Issues Resolved

  • #2008 The \underline and \overline commands now render correctly.
  • #1996, #2025 MathML output could occasionally be incorrect for the
    \left...\right command
  • #2009 Chemical equations did not render correctly
  • #1990 The closing delimiter of a \left...\right command was incorrectly
    adopting the style of the last atom inside the command.
  • #2044 When overflowing the mathfield using the virtual keyboard, the caret
    would be hidden from view.
  • #2000, #2016 Correctly handle when the root is not a group, i.e. when
    it's a multi-line array.

0.94.8 2023-06-15

Improvements

  • On RTL system, do not flip the direction of the virtual keyboard keycaps rows

New Contributors

Full Changelog: https://github.com/arnog/mathlive/compare/v0.94.7...v0.100.0

mathlive - 0.94.7 Latest Release

Published by arnog over 1 year 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.
mathlive - 0.94.0

Published by arnog over 1 year 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/

mathlive - v0.63.0

Published by arnog over 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.
mathlive - v0.62

Published by arnog over 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().
mathlive - v0.58

Published by arnog about 4 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
mathlive - v0.56.0

Published by arnog about 4 years ago

mathlive - v0.55.0

Published by arnog about 4 years ago

mathlive - v0.54.1

Published by arnog over 4 years ago

mathlive - v0.54.0

Published by arnog over 4 years ago

mathlive - v0.53.3

Published by arnog over 4 years ago

mathlive - v0.53.2

Published by arnog over 4 years ago

mathlive - v0.53.1

Published by arnog over 4 years ago

mathlive - v0.53.0

Published by arnog over 4 years ago

mathlive - v0.52.0

Published by arnog over 4 years ago

mathlive - v0.51.1

Published by arnog over 4 years ago

mathlive - v0.51.0

Published by arnog over 4 years ago

0.51.0 (2020-05-19)

New Features

  • #450 Custom keybindings. A keybinding (also called keyboard shorcut)
    associate a keystroke combination on a physical keyboard with a command.
    Mathlive previously had some built-in keybindings, but now they can be
    extended or replaced.
    See config.keybindings and Keybinding.

  • Added setKeyboardLayout() and setKeyboardLayoutLocale() functions to
    customize the current physical keyboard layout.

Improvements

  • #461 The array editing commands only worked in math mode. They now apply
    in text mode as well.

  • #459: Add a placeholder for incomplete commands, for example entering
    \frac in command mode.

  • Added some missing commands: deleteNextChar, deletePreviousChar,
    deleteNextWord, deletePreviousWord, deleteToGroupStart, deleteToGroupEnd,
    deleteToMathFieldEnd, moveToSubscript, applyStyle, toggleVirtualKeyboard,
    hideVirtualKeyboard, showVirtualKeyboard

  • In some cases, the top of the placeholder character could be cut off.

Bug Fixes

  • The Read Aloud feature would not work when a Neural Engine AWS voice
    was used (such as Joana or Matthew)

  • In the Vue wrapper, the onKeystroke handler would error

  • Styling (applying color, style) was disabled. This also affected mode change
    (i.e. alt+= to switch between text and math mode)

  • After completing a command in command mode (i.e. pressing the return key), the mode did not switch not math mode and remained in command mode.

mathlive - v0.50.8

Published by arnog over 4 years ago

Improvements

  • The Symbols keyboard is now a top-level keyboard. Previously it was accessible
    only from the Roman keyboard.
  • Added some standard Latex commands: \inf, \Pr, \liminf, \limsup
  • Added inline shortcuts for some commands: sinh, cosh, sec, csc,
    cot, arcsin, arccos, arctan
  • When generating Latex output, only insert spaces when necessary (i.e. after
    commands that are followed by a letter). Conversely, always generate the space
    when necessary (\rbrack a would generate \rbracka)
  • Minor rendering performance improvement

Bug Fixes

  • The absolute value character "|" (and other small delimiters) would be
    displayed in the wrong font (and too small)

  • The absolute value key from the virtual keyboard would
    insert '|#@|'

  • The 'sqrt' key from the virtual keyboard or keyboard shortcut
    (option+V) would do nothing. The problem affected any inline shortcut or key
    that included a '#0' argument when there was no selection

  • Fixed an issue with long inline shortcuts that could trigger text mode
    (e.g. 'arcsin') and never apply the inline shortcut

  • Do not trigger smart mode conversion with arrow keys

  • Fixed an issue on iOS 12 and Firefox/Android where the Mathfield could not be
    focused (fix contributed by (https://github.com/beneater)

mathlive -

Published by arnog over 4 years ago

Fix #448: Fix an issue where the "^" keyboard shortcut would not work.

mathlive -

Published by arnog over 4 years ago

0.50.4 (2020-05-09)

Bug Fixes

  • Fix #444 The "x^2" key in the virtual keyboard did not work as expected.
Package Rankings
Top 1.49% on Npmjs.org
Badges
Extracted from project README
Maintenance GitHub license