Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mathlive-tera

Package Overview
Dependencies
Maintainers
0
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathlive-tera - npm Package Versions

1
6

0.99.5

Diff

mauhieu12
published 0.99.4 •

mauhieu12
published 0.99.3 •

mauhieu12
published 0.99.2 •

mauhieu12
published 0.99.1 •

mauhieu12
published 0.99.0 •

Changelog

Source

0.99.0 2024-06-10

Breaking Changes

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

  • The mf.setCaretPoint() method has been replaced with mf.position = 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.
mauhieu12
published 0.98.0 •

Changelog

Source

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, <kbd>ALT</kbd>+<kbd>/</kbd> would insert a \/ command, which is not standard. Now, the simple / is inserted.

mauhieu12
published 0.97.5 •

mauhieu12
published 0.97.4 •

Changelog

Source

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.
mauhieu12
published 0.97.3 •

Changelog

Source

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 (<kbd>SHIFT</kbd>+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 <kbd>TAB</kbd> 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.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc