Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Snyk has created this PR to upgrade multiple dependencies.
👯♂ The following dependencies are linked and will therefore be updated together.ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
mathlive
from 0.69.10 to 0.101.0 | 90 versions ahead of your current version | 2 months ago
on 2024-07-17
next
from 12.1.0 to 12.3.4 | 212 versions ahead of your current version | 2 years ago
on 2022-11-21
Release notes
Package name: mathlive
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 acustom 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 dataassociated with the event.
To handle the event, add an event listener to the mathfield element:
0.99.0 2024-06-10
Breaking Changes
The
mf.offsetFromPoint()
method has been renamedmf.getOffsetFromPoint()
The
mf.scriptDepth()
andmf.hitboxFromOffset()
methodds have beenreplaced with
mf.getElementInfo()
.The
getElementInfo()
method provides more information including any idthat may have been applied with
\htmlId{}
.It is useful from within a
click
handler to get more information about theelement that was clicked, e.g.
The info returned is an object with the following properties:
/* 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 itsargument 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 thea
andb
in bold,but the
+
in normal weight. Characters rendered by\mathbf
are renderedupright, even if they would have been rendered as italic otherwise.
The
\boldsymbol
command is an alternative to\mathbf
that affects morecharacters, 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 thebm
package is a more modern alternative thataffects 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, andfall back to
\bm
when not. This should result in more consistent renderingof bold text.
When parsing, MathLive will interpret both
\mathbf
,\boldsymbol
and\bm
asbold.
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
switch-mode
command has two optionals arguments, a prefixand suffix. The prefix is inserted before the mode switch, and the suffix
after. The command was behaving incorrectly. It now behaves as expected.
selecting a fraction
\frac{a}{b}
and pressingalt+shift+T
will convert theselection to
(a)/(b)
. Pressingalt+shift+T
again will convert it back to\frac{a}{b}
.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 linkto 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 numberof 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 isalso 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 theiruppercase 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 (aMathfieldElement
) to theonMenuSelect
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 moreconcise and easier to read.
Issues Resolved
some cases.
keydown
andinput
event is now consistentwith the
<textarea>
element.in unexpected behavior. Now, pressing the backspace key after a shortcut
has been typed will undo the conversion of the shortcut.
would be dispatched.
123{,}4(1)
),do not use a
\left...\right
command in order to get the proper spacing.\int
was incorrect.
correctly in Safari.
\textit{}
), the content couldsometimes be serialized with an unnecessary
\text{}
command, i.e.\text{\textit{...}}
.smart-fence
was off, the{
and}
keys would not insertbraces.
\sqrt[#?]{1}
from the#?
position, a runtime exception would occur.
correctly focus the mathfield.
in a context menu would appear to be selected.
preserved. In addition, when using a controlled component with React an
unnecessary update is avoided.
style is no longer adopted by subsequent characters.
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.
is constructed.
before-virtual-keyboard-toggle
andvirtual-keyboard-toggle
events are now dispatched on thewindow.mathVirtualKeyboard
object of the iframe. This can be used to detecta request (and prevent) for the virtual keyboard to be displayed.
\mathcal{C}
it would not be displayed correctly in the "Solve for" menu.
\mathrlap
command was incorrectly rendering like\mathllap
.0.98.6 2024-01-27
New Features
StaticRenderOptions.TeX.className
to specify that an element with thespecified class name should be rendered as a LaTeX formula.
--keycap-width
CSS variable to specify the width of akeycap 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
CSSunit. If the browser does not support the
cq
CSS unit, this CSS variable canbe used to specify the width of the keycap. (See #2028, #2133)
gather*
environmentvariant.
Issues Resolved
renderToMarkup()
orrenderToMathML()
in aserver-side environment, a runtime error would occur.
when the last or first prompt is reached.
²
orℂ
are nowinterpreted as their LaTeX equivalent only when in math mode.
\iff
now renders correctlymf.value
property would not always update the valueof the mathfield.
the virtual keyboard would result in the mathfield losing focus and the
virtualy keyboard closing.
keyboard would be clipped.
renderMathToElement()
orrenderMathInDocument()
, coalesceadjacent text nodes.
\cfrac
optional alignment argument\bf
,\bfseries
,\mdseries
,\upshape
,\itshape
,\slshape
,\scshape
,\rmfamily
,\sffamily
,\ttfamily
are nowinterpreted correctly.
\operatorname
is now spoken correctlyrendered incorrectly.
0.98.5 2023-12-27
Issues Resolved
When a font size command is inside a
\left...\right
command, apply the fontsize 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ℂ
, correctlyinterpret 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, correctlyinterpret the superscript as an exponent, not as a function argument.
#787, #1869 The
f
,g
andh
symbols are no longer hardcoded assymbols 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
todetermine if the domain of a symbol is a function.
This can be customized by setting the
isFunction
property of the mathfieldor by declaring a symbol as a function using the
declare()
method of thecompute engine. For example:
In addition, a new
isImplicitFunction
hook has been added which can be usedto indicate which symbols or commands are expected to be followed by an
implicit argument. For example, the
\sin
function can be followed by animplicit argument without parentheses, as in
\sin \frac{\pi}{2}
. Thisaffects the editing behavior when typing a
/
after the function. If animplicit 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 nowcorrectly update the value of the mathfield.
#2225 For consistency with
<textarea>
, when setting the value change theselection 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
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
0.98.0 2023-12-03
Breaking Changes
The
mf.setPromptContent()
method has been renamed tomf.setPromptValue()
for consistency with the
mf.getPromptValue()
method.The
mf.stripPromptContent()
method has been removed. Its functionality canbe achieved with:
Improvements
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:
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 theDOM 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 theplaceholder
attribute of a
<textarea>
element. This specifies a short hint as a LaTeXstring 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 thegetValue()
method. This format is similar to the
"latex"
format, but does not includethe 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 willnow 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
.row
class was defined, it would be applied to the virtualkeyboard rows, resulting in incorrect layout.
Improvements
mf.queryStyle()
method to query the style of a selection or thecurrent style if no selection.
0.97.3 2023-11-28
Improvements
The
mode-change
event is now dispatched more consistently when the modechanges.
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 theDOM 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
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:
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 themathfield. The value of this property is an array of menu items. See
the documentation for details.
Improvements
appears after a delay.
Issues Resolved
\pmod5
is now correctly parsed as\pmod{5}
. Macros thatused an argument that was not a literal group were not parsed correctly.
0.96.2 2023-11-16
Issues Resolved
some cases.
MathfieldELement.locale
orMathfieldElement.strings
would not affect existing mathfields.
mf.locale
insteadof
MathfieldElement.locale
) will now throw an error.smartFence
was on, an inline shortcut that conflicted with adelimiter was ignored.
Improvements
including
\mapsfrom
.user-select
CSS property.If it is set to
none
, the mathfield will not be selectable.0.96.1 2023-11-15
Improvements
mf.registers.arraystretch = 1.5
instead of mf.registers = {...mf.registers,arraystretch: 1.5}`
\renewcommand
, for example\renewcommand{\arraystretch}{1.5}
[up]
and[down]
to move the selection up or down ina matrix.
when the virtual keyboard is not visible.
Issues Resolved
origin
\left...\right
was vertically offset.[hide-keyboard]
virtual keycap would cause a runtimeerror.
geometrychange
event isdispatched.
0.96.0 2023-11-14
Breaking Changes
serializeMathJsonToLatex()
has been renamed toconvertMathJsonToLatex()
for consistency.Issues Resolved
(f(x))
would be parsed as(f(x)
.would not recognize the left argument as a numerator.
command, for example
(
was interpreted as \lparen`. This could cause someinteroperability issues.
\operatorname
command, some of the commands could fail to render. Forexample, typing "1mm + 2mm" in a mathfield would result in "1 + 2mm" to be
displayed.
verbatimLatex
associated with theatom, so that the
value
property of the atom is correctly serialized.moveToMathfieldEnd
command, the selection was not changedif it was not collapsed and already at the end of the mathfield. Similarly for
moveToMathfieldStart
.Improvements
mathtools
,actuarialangle
,colonequals
,statmath
andamsopn
packageslongdiv
enclosure (\mathenclose{longdiv}{...}
).
) in the virtual keyboard was displayed as ablank key.
a keycap was in a pressed state.
shift +
in the numeric keyboard was inserting a sumwith limits contrary to what the keycap label indicated.
,
key now produces a semicolon whenshifted and has a variant panel with additional punctuation.
itself.
\cdot
instead of
\times
. Use shift to produce\times
.