You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

mathlive

Package Overview
Dependencies
Maintainers
1
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathlive - npm Package Versions

2345
18

0.105.0

Diff
arnog
published 0.105.0 •

Changelog

Source

0.105.0 2025-03-27

Breaking Changes

In order to support alternate CDNs, in particular jsdelivr, the file layout of the npm package has changed. The files that were previously in the ./dist/ directory are now in the root of the package. This should not affect most users, but if you are importing the library or auxiliary files from the dist directory, you will need to update your paths.

To use jsdelivr, use:

import { MathfieldElement } from "https://esm.run/mathlive";

or:

<script defer src="https://cdn.jsdelivr.net/npm/mathlive"></script>

Issues Resolved

  • #2647, #2634, #2562 Some accents (\hat{}, \vec{}) where not rendered correctly in some cases.

  • #2635 In Chrome (and Firefox), clicking on the padding area of the mathfield would not result in the focus getting into a zombie state and keyboard event no longer being dispatched.

arnog
published 0.104.2 •

Changelog

Source

0.104.2 2025-03-23

Issues Resolved

  • #2588 With Chrome 133+ input with the physical keyboard was disabled after showing the virtual keyboard.
arnog
published 0.104.1 •

Changelog

Source

0.104.1 2025-03-18

Improvements

  • Improved support for the jsdelivr CDN. To use it, use
    import { MathfieldElement } from "https://esm.run/mathlive";

Issues Resolved

  • #2628 Attempting to delete an empty line in a multiline environment would not delete the line.
  • #2585 In some cases, the arguments of a macro were not serialized correctly. This could happen when using a macro in conjunction with a inline shortcut.
  • #2586 The \pdiff{}{} command was not properly serialized to LaTeX.
arnog
published 0.104.0 •

Changelog

Source

0.104.0 2025-02-08

Security Advisories

As a reminder, if you are handling untrusted input, you should consider using the MathfieldElement.createHTML() method to sanitize content. The createHTML() method follows the recommendations from the Trusted Type specification.

For example, using the DOMPurify library (there are other HTML sanitizers available):

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.2.3/purify.min.js"></script>
MathfieldElement.createHTML = (html) => DOMPurify.sanitize(html);
  • security advisory Untrusted input could be used to inject arbitrary HTML or JavaScript code in a page using a mathfield or math content rendered by the library, if the content included an \htmlData{} command with maliciously crafted input and no DOM sanitizer was used.

    The content of the \htmlData{} command is now sanitized and the 🚫 emoji is displayed instead in the mathfield if the content is unsafe. When using convertLatexToMarkup(), an exception is thrown.

  • The \href{}{} command now only allows URLs with the http or https protocol.

Issues Resolved

  • Generate only standard trigonometric functions, i.e. those available in the amsmath package. Use \operatorname{} for the others. The standard commands are:

    • \arccos
    • \arcsin
    • \arctan
    • \arg
    • \cos
    • \cosh
    • \cot
    • \coth
    • \csc
    • \sec
    • \sin
    • \sinh
    • \tan
    • \tanh
  • Added support for \dddot and \ddddot commands.

  • #2573 The \operatorname{} command when round-tripped would incldue an extraneous \mathrm{} command.

  • #2132, #2548 Improved handling of multi-line mathfields. To use a multi-line mathfield, include a multi-line environment:

    • \displaylines{}: single column of left-aligned equations
    • gather: single column of centered equations
    • multline: centered equations with the first line aligned left and the last line aligned to the right
    • align: two columns, the first column right-aligned, the second column left-aligned; used for one equation per line
    • split: two columns of equations, the first column right-aligned, the second column left-aligned; used for a single equation split over multiple lines

For example:

<math-field>\displaylines{x=1 \\y = 2}</math-field>
<math-field>\begin{align}
  f(0) &= 1 \\
  f(x + 1) &= f(x-1) + f(x)
\end{align}
</math-field>
  • When in a multi-line environment, the Return key will move to the next line. The Backspace key will delete the current line if the cursor is at the beginning of the line. Note that no placeholder is inserted on a new line: the line is simply blank.

  • The Add Row Before, Add Row After, Add Column Before, Add Column After, Delete Row and Delete Columns commands are available in the context menu when the cursor is inside a matrix. They are not available in multi-line environments.

  • #2574 The commands \coloneq, \Coloneq, \Coloneqq, \eqcolon and \Eqcolon were mapped to incorrect symbols (some of them used obsolete definitions of those commands from the mathtools package that changed in the Summer of 2022). They are now correctly mapped to the corresponding symbols.

  • #2576 The command \perp was mapped to the wrong symbol (U+22A5). It is now mapped to the correct symbol (U+27C2)

  • Improved ASCIIMath serialization.

arnog
published 0.103.0 •

Changelog

Source

0.103.0 2024-12-10

Issues Resolved

  • #2530 The AsciiMath 1/2 is now parsed as \frac{1}{2}
  • The \displaylines command is now correctly parsed as a command with an argument, not as a group command.
arnog
published 0.102.0 •

Changelog

Source

0.102.0 2024-11-29

Issues Resolved

  • #2550 The subpath exports in the main package.json have been updated to comply with Node.js's subpath patterns, which utilize "direct static matching and replacement.

Improvements

  • #2554 Option for sticky virtual keyboard variant panel

    When long pressing a key on the virtual keyboard, a variant panel is displayed that offers alternatives (variants) for that key. The panel is only displayed while your finger is pressing the key (like a smartphone keyboard). This new options allows the variant panel to remain displayed even if you lift your finger from the screen.

    Add the stickyVariantPanel property to a virtual keyboard keycap definition to make the variant panel sticky.

    See ./examples/sticky-variant-panel/ for an example.

arnog
published 0.101.2 •

Changelog

Source

0.101.2 2024-11-15

Issues Resolved

  • Correctly display the caret following a \mathop{} command.
  • #2540 When using renderMathInElement() some white space was occasionally incorrectly removed.
  • #2545 (?) Use \rightarrow instead of \rarr in the virtual keyboard.
  • #2543 The MathfieldElement.fractionNavigationOrder was not respected when navigating in a fraction with the arrow keys.
  • #2251 Fixed the serialization of \displaylines{}
arnog
published 0.101.1 •

Changelog

Source

0.101.1 2024-10-15

Issues Resolved

  • #2533 When using the virtual keyboard to insert a character with a blackboard style followed by a non-alphabetic symbol without a blackboard style, the second symbol would incorrectly be serialized with a blackboard style.
  • In some cases, the placeholder attribute would not be displayed when the mathfield was empty.
  • When using static math, the font-familly for text content was not correctly inherited from the parent element.
  • In some cases, the inherent style of a macro could get overriden. For example typing the "RR" inline shortcut resulted in an unstyled R instead of the expected blackboard R.
arnog
published 0.101.0 •

Changelog

Source

0.101.0 2024-07-17

Breaking Changes

  • The properties mathVirtualKeyboard.actionKeycap, mathVirtualKeyboard.shiftKeycap, mathVirtualKeyboard.backspaceKeycap, and mathVirtualKeyboard.tabKeycap have been removed. Use the more general mathVirtualKeyboard.setKeycap() method to customize these keycaps, that is mathVirtualKeyboard.setKeycap('[action]', {...}) etc...

Improvements and New Features

  • Macros can now be specified with renderMathInElement() and renderMathInDocument() using the macros option. For example:

    renderMathInElement(element, {macros: {RR: '\\mathbb{R}'}})
    
  • Performance improvements for pages with many mathfields. The initial rendering can be up to 2x as fast.

  • Some keycaps in the virtual keyboard can be customized without having to define an entire virtual keyboard layout.

    The mathVirtualKeyboard.getKeycap() give access to the definition of special keycaps and mathVirtualKeyboard.setKeycap() can be used to change that definition.

    The keycaps are one of these special shortcuts:

    • [left], [right], [up], [down], [return], [action],
    • [space], [tab], [backspace], [shift],
    • [undo], [redo], [foreground-color], [background-color],
    • [hide-keyboard],
    • [.], [,],
    • [0], [1], [2], [3], [4],
    • [5], [6], [7], [8], [9],
    • [+], [-], [*], [/], [^], [_], [=], [.],
    • [(], [)]

    For example, to change the LaTeX inserted when the multiplication key is pressed use:

    mathVirtualKeyboard.setKeycap('[*]', {latex: '\\times'});
    

Issues Resolved

  • #2455 Serialization to ASCII Math of brackets and braces is now correct.
  • When using Chrome in some locale (such as es-419), the context menu would not be displayed.
  • When the MathfieldElement.isFunction handler is updated, re-render all the mathfields on the page to take it into account.
  • #2415 A content change event is now dispatched when the value of the mathfield is changed as a result of switch from LaTeX mode to math mode by changing the selection.
  • Dispatch a contextmenu event any time the context menu is about to be displayed. This allows the event to be canceled.
  • #2413 When setting the alphabeticLayout, the current keyboard would not be updated in some cases.
  • #2412 The serialization of some expressions to LaTeX could result in some spaces being omitted. For example, \lnot p would serialize as \lnotp.
  • #2403 The virtual keyboard Keycap Variants panel was positioned incorrectly when the page used a RTL layout direction.
  • In the virtual keyboard, the background of the variant panel was sometimes displayed transparently.
  • #2402 Characters inserted after a \mathbb{} command were not styled correctly.
  • The math-virtual-keyboard-command event was not dispatched when a mathfield was focused and a keycap was pressed.
  • There are now CSS selectors to customize the size of glyphs in the virtual keyboard (shift, enter, etc...):
    • --keycap-glyph-size
    • --keycap-glyph-size-lg
    • --keycap-glyph-size-xl
  • #2397 When a beforeinput event was canceled, the text would still be inserted when using the physical keyboard.
  • #2398 When a placeholder was the only element in a group, i.e. {\placeholder{}}, the placeholder was not automatically selected.
arnog
published 0.100.0 •

Changelog

Source

0.100.0 2024-06-12

Issues Resolved

  • #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.

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

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

    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: "dispatchEvent('customEvent', {detail: 'some data'})"
      }
    

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

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