Changelog
0.66.0 2021-05-20
horizontalSpacingScale
option is deprecated. It will be removed in an
upcoming version and replaced by the standard TeX registers \thinmuskip
,
\medmuskip
and \thickmuskip
.default-mode
attribute (or the defaultMode
property) of a
<math-field>
element is set to "inline-math"
, the element will be
displayed as an inline element. Previously, the defaultMode
affected the
layout of the math content, but the element still behaved as a block.renderMathInDocument()
now creates a <div>
when using Display Style, and a
<span>
when using Text Style (inline math).<math-field>
when using
the \class
command.virtual-keyboard-mode
) are now reflected as a property on the element
mf.virtualKeyboardMode
as a shortcut to
mf.setOptions({virtualKeyboardMode:...}
. This also allows to set these
properties before the component is connected to the document.<math-field>
: plonk-sound
,
keypress-sound
. Setting them to 'none' turn off these sounds.MacroPackageDefinition
)amsmath.sty
) when
copying/pasting, while still expanding custom macros for improved
compatibility.\darr
\dArr
\Darr
\lang
\rang
\uarr
\uArr
\Uarr
\N
\R
\Z
\alef
\alefsym
\Alpha
\Beta
\bull
\Chi
\clubs
\cnums
\Complex
\Dagger
\diamonds
\empty
\Epsilon
\Eta
\exist
\harr
\hArr
\Harr
\hearts
\image
\infin
\Iota
\isin
\Kappa
\larr
\lArr
\Larr
\lrarr
\lrArr
\Lrarr
\Mu
\natnums
\Nu
\Omicron
\plusmn
\rarr
\rArr
\Rarr
\real
\reals
\Reals
\Rho
\sdot
\sect
\spades
\sub
\sube
\supe
\Tau
\thetasym
\weierp
\Zeta
amsmath
commands:\varGamma
\varDelta
\varTheta
\varLambda
\varXi
\varPi
\varSigma
\varUpsilon
\varPhi
\varPsi
\varOmega
\displaylimits
commandSee Supported TeX/LaTeX Commands for more details.
LimeGreen
is a valid color, Limegreen
is not)\int
command using the
keyboard.value
for the mathfield element when it is not attached
yet, even if the output format is not specified.rgb()
function would not render correctly if the
arguments contained some spaces, e.g.rgb ( 255 , 255 , 255 )
.Changelog
0.65.0 2021-05-14
substituteTextArea
option has been removed. This option was in fact not
working so removing it will presumably have no impact.\underline
, \underbrace
, \xleftarrow
, etc... to
the virtual keyboard.\\
(double-dash, i.e. end of line in tabular
mode) as a valid command prefix.\{
as a command by default.\bigstar
symbolrenderMathInDocument()
when there are many formulas
on the page.Span
to Box
.Changelog
0.64.0 2021-05-09
The FontSize
type is now an integer between 1 and 10. It previously was
size1
, size2
, etc... The default font size is 5
, the smallest is 1
.
However, when using applyStyle()
, the size can still be specified with
size1
, etc... The following size values can also be used: tiny
,
scriptsize
, footnotesize
, small
, normal
or normalSize
, large
,
Large
, LARGE
, huge
, Huge
.
Previously, named colors (yellow
, red
...) mapped to the dvips
color set.
They can now map to different values to improve their legibility. To ensure
that a particular color is used, specify the colors as a hex triplet
(#dd2233
). See also the colorMap
option.
The following color names are recommended: they will map to values that have been optimized for legibility as a foreground or background color, they cover all the hues of the color circle and have been adjusted to provide similar apparent brightness and intensity:
orange
, yellow
, lime
, green
, teal
, blue
, indigo
,
purple
, magenta
black
, dark-grey
, grey
, light-grey
, white
The background of fractions, radicals and parentheses group (\left
/\right
commands) is now highlighted when they contain the caret. This makes it easier
to distinguish some cases when the cursor is at the edge of the element and
could be either inside or outside. The appearance of the highliting can be
controlled with the <del>--contains-highlight
</del>
--contains-highlight-background-color
CSS variable. Set it to transparent
to restore the previous behavior.
colorMap
option. To map a color name such as "yellow" to a custom RGB
color, set the colorMap
or backgroundColorMap
option to a function that
takes the color name as an argument and return a matching CSS RGB string.
Return undefined
to proceed with the default mapping.
In macro dictionary, added option to expand or not the macro when using the
latex-expanded
output format (when copying to the clipboard, for example).
Added the \overunderset{}{}{}
command.
Added the \lparen
and \rparen
delimiters.
Added the \mod
, \pmod
and \bmod
commands, defined as macros.
Added support for dashed column separators in matrix, using ":" in the matrix preamble. See the arydshln package.
Added support for optional below argument to \stackrel
and \stackbin
as
per the
stackrel package
When using renderMathInDocument()
or renderMathInElement()
, ASCII Math
format can be used. The default delimiters for ASCII Math are
"" (backtick) and can be changed with the
asciiMath.delimitersoption. To turn off this conversion and revert to the previous behavior, call
renderMathInDocument({
asciiMath: null })`
Substantial rewrite of the stacked layout algorithm (fractions, superscripts,
etc...). The previous algorithm did not work correctly when mixing absolute
sizing commands (\Huge
) and relative ones (\scriptstyle
) and had various
issues and inconsistencies with what TeX produced. The result is now close to
TeX.
Display the placeholder symbol using the caret color.
Added the --smart-fence-opacity
and --smart-fence-color
CSS variables.
In the layout of superscript/subscript and accents, use the correct font metrics for spacing and layout (previously, the font metric for the base size was always used). This may result in very slightly different placement of superscripts, subscripts and limits (but closer to TeX).
Fixed cases where the inter-atom spacing was incorrect (when spacing atoms or super/subscripts were used with a binary atom, or when some other atom types were used, such as BoxAtom and more).
When pasting from the clipboard, recognize text bracketed with
\begin{math}
...\end{math}
or \begin{displaymath}
...\end{displaymath}
as LaTeX (in addition to $
, $$
, \[
...\]
and \(
...\)
which were
recognized before). Also, recognize text that may contain a LaTeX expression
surrounded by regular text (i.e. "if $x > 0$").
When pasting ASCIIMath, recognize more expression using standard functions such as the trig functions.
Recognize text content surrounded with "`" (backtick) delimiters as ASCII Math.
When copying to the clipboard, roundtrip verbatim latex when available, i.e. the content of the clipboard will be exactly what has been pasted in if the formula has not been edited.
The default color mapping function now returns different values when used as a line color or as a background color. This improves the legibility of colors. See MathLive Guide: Customizing.
Paste operations are now undoable.
Avoid generating unnecessary empty span for limits and other constructs.
Avoid repeating color attributes on child elements by lifting them to an appropriate parent. As a consequence, when a background color is applied it is displayed more uniformly than previously.
Reduced the size of the font-metrics table.
Increased the number of automated and static tests.
+-
) was incorrect, as well as
some other combinations.\sqrt
, \placeholder
and many other atoms when a mathstyle
is applied with commands such as \textstyle
, \scriptstyle
, etc...\widehat
).renderMathInDocument()
and the document contained a
mathfield with a value that contained exclusively an environment, the
mathfield would not render (the \begin{}
would be incorrectly rendered by
renderMathInDocument()
).renderMathInElement()
or renderMathInDocument()
use the same
default letterShapeStyle
as when using a mathfield, that is, french
if the
locale is French, tex
otherwise.getValue('latex')
will return exactly what was input.\exponentialE
: when a superscript/subscript was
applied to a macro, the latex output would become blank.\scriptstyle
would crash.skipBoundary
atom.\sqrt[\placeholder{}}{x}
\rule{}{}
) were not clickable and did not appear selected.\char
command when using latex-expanded
format.Changelog
0.63.0 2021-04-24
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.version
(previously available as MathLive.version
).infty
and int
inline shortcuts.Changelog
0.62.0 2021-04-23
OverUnder
atoms (\overset
, etc...).renderMathInElement()
or renderMathInDocument()
,
formulas containing styling information would get too aggressively coalesced,
dropping some styling.renderMathInElement()
or renderMathInDocument()
.Changelog
0.61.0 2021-04-22
Some format options have been renamed:
| Before | Now |
| :------------------------------- | :-------------------------------- |
| "spoken-ssml-withHighlighting"
| "spoken-ssml-with-highlighting"
|
| "mathML"
| "math-ml"
|
| "ASCIIMath"
| "ascii-math"
|
The old spelling is still accepted at runtime but it has been deprecated and you will be removed in a future update.
captureSelection
flag from being selectable.woff
fonts. This change should be transparent, as all supported
browsers support woff2
at this point.\Huge
) to math mode. TeX is inconsistent in how
it handles those. We choose to always apply them in math mode.dcases
environment: like cases
but in displaystyle
by
default.\mbox
by avoiding wrapping it with an unnecessary
\text
command.plonkSound
or keypressSound
option to null
will
suppress sound feedback.keycap
class no
longer needs to be specified for each keycap.defaultMode
property or the default-mode
attribute can be set to a
value of inline-math
to set the mathfield in inline math \textstyle
by
default.\htmlData
, \cssId
and \class
commands.\cdot
. The incorrect
styling resulted in incorrect measurement and vertical layout of some
characters.\ne
, \neq
and \not
.renderMathInElement()
or renderMathInDocument()
do not
duplicate the accessible node.e^x
and d/dx
in the functions
virtual keyboard\displaystyle
, \textstyle
, \scriptstyle
and
\scriptscriptstyle
commands: they apply to the commands to their right.\displaystyle
applies to the
current cell only (not the whole array).skipBoundary
flag would not skip it.skipBoundary
, only the first one would be
skipped.\int
now accounts for the slant of the symbol.convertLatexToMarkup()
or renderMathInDocument()
properly wrap
the generated atoms in a root atom. Without it, some atoms render differently
in static mode than in interactive mode.\overset
(they are adjacent, not over,
unlike \overbrace
).cases
environment should be in inline mode (textstyle
) by default.\overbrace
, \underbrace
, etc...Changelog
0.60.1 2021-04-13
vite
bundler, the library location could not be determined
correctly. As a result, the assets (fonts and sounds) could not be loaded when
in their default location.\enclose{roundedbox}
and other variants.setOptions()
avoid changing the selection unless
necessary (react-mathlive issue #4).Changelog
0.60.0 2021-04-12
Renamed getCaretPosition()
and setCaretPosition()
to get/set caretPoint
.
"Position" refers to where the caret/insertion point is, as an offset inside the expression. These methods return client screen coordinates and the new name better reflect the correct terminology.
Removed deprecated (April 2019) method enterCommandMode()
Replaced ignoreSpacebarInMathMode
option with mathModeSpace
. The
ignoreSpacebarInMathMode
was accidentally not working (#859). However,
the boolean form is problematic as an element attribute (it defaults to true,
but element attributes default to false). It has been replaced with
mathModeSpace
which is more flexible (you can specify which space to use)
and doesn't have the issue of the default boolean value.
Support for iframes. Multiple mathfields in a single document but in different iframes can now share a single virtual keyboard. In the main document, use:
makeSharedVirtualKeyboard({
virtualKeyboardLayout: 'dvorak',
});
And in the iframes, use the use-shared-virtual-keyboard
attribute:
<math-field use-shared-virtual-keyboard></math-field>
See examples/iframe
for more info.
Contribution by https://github.com/alexprey. Thanks!
#555 Support for IME (Input Method Engines) for Japanese, Chinese, Korean and other complex scripts.
applyStyle()
has now more options. Previously it always toggled the style of
the selection. Now it can either toggle or set the style, and modify the
selection or a specific range.
#387 find()
method to search the fragments of an expression that match a
LaTeX string or regular expression.
For example the following code snippet will add a yellow background to the fractions in the expression:
mf.find(/^\\frac{[^}]*}{[^}]*}\$/).forEach((x) => {
mf.applyStyle({ backgroundColor: 'yellow' }, x, {
suppressChangeNotifications: true,
});
});
#387 replace()
method to replace fragments of an expression.
This method is similar to the replace()
method of the String
class. The
search pattern can be specified using a string or regular expression, and the
replacement pattern can be a string or a function. If using a regular
expression, it can contain capture groups, and those can be references in the
replacement pattern.
The following snippet will invert fractions in a formula:
mf.replace(/^\\frac{([^}]*)}{([^}]*)}$/, '\\frac{$2}{$1}');
New LaTeX Mode
This mode replaces the previous Command Mode. While the Command Mode (triggered by pressing the \ or ESC key) was only intended to insert a single LaTeX command (e.g. "\aleph"), the LaTeX Mode is a more comprehensive LaTeX editing mode.
To enter the LaTeX Mode, press the ESC key or the \ key. While in this mode, a complex LaTeX expression can be edited. Press the ESC or Return key to return to regular editing mode.
To quickly peek at the LaTeX code of an expression, select it, then press ESC. Press ESC again to return to the regular editing mode.
To insert a command, press the \ key, followed by the command name. Press the TAB key to accept a suggestion, then the RETURN key to return to regular editing mode (previously pressing the TAB key would have exited the command mode).
Added soundsDirectory
option to customize the location of the sound files,
similarly to fontsDirectory
.
Enabled audio feedback by default.
#707 added support for \begin{rcases}\end{rcases}
(reverse cases
, with
brace trailing instead of leading)
#730 added new CSS variables to control the height of the virtual keyboard:
--keycap-height
--keycap-font-size
--keycap-small-font-size
(only if needed)--keycap-extra-small-font-size
(only if needed)--keycap-tt-font-size
(only if needed)#732 Support for Dvorak keyboard layout
Synchronize the virtual keyboard layout (QWERTY, AZERTY, etc...) with the physical keyboard layout.
Added \htmlData
command, which takes as argument a comma-delimited string of
key/value pairs, e.g. \htmlData{foo=green,bar=blue}
. A corresponding
data-foo
and data-bar
DOM attribute is generated to the rendered DOM.
read-only
mode, it was still possible to
delete a portion of it by pressing the backspace key.typedText
selector dropped its options argument. As a result, the sound
feedback from the virtual keyboard only played for some keys.<math-field>
element the command popover did not
display correctly.plain/text
item.alt+e
, and they are properly
displayed as a composition (side effect of the fix for #555).Complete rewrite of selection handling.
This is mostly an internal change, but it will offer some benefits for new capabilities in the public API as well.
Warning: This is a very disruptive change, and there might be some edge cases that will need to be cleaned up.
The position of the insertion point is no longer represented by a path. It is now an offset from the start of the expression, with each possible insertion point position being assigned a sequential value.
The selection is no longer represented with a path and a sibling-relative offset. It is now a range, i.e. a start and end offset. More precisely, the selection is an array of ranges (to represent discontinuous selections, for example a column in a matrix) and a direction.
These changes have these benefits:
onDelete
function now regroups all the
special handling when pressing the Backspace and Delete keys.find()
method
which returns its results as an array of ranges. It is also possible now to
query and change the current selection, and to apply styling to a portion of
the expression other than the selection.On a historical note, the reason for the original implementation with paths
was based on the TeX implementation: when rendering a tree of atoms (which TeX
calls nodes), the TeX layout algorithm never needs to find the parent of an
atom. The MathLive rendering engine was implemented in the same way. However,
for interactive editing, being able to locate the parent of an atom is
frequently necessary. The paths were a mechanism to maintain a separate data
structure from the one needed by the rendering engine. However, they were a
complex and clumsy mechanism. Now, a parent
property has been introduced in
instance of Atom
, even though it is not necessary for the rendering phase.
It does make the handling of the interactive manipulation of the formula much
easier, though.
Changes to the handling of sentinel atoms (type "first"
)
This is an internal change that does not affect the public API.
Sentinel atoms are atoms of type "first"
that are inserted as the first
element in atom branches. Their purpose is to simplify the handling of "empty"
lists, for example an empty numerator or superscript.
Previously, these atoms where added when an editable atom tree was created,
i.e. in the editor
code branch, since they are not needed for pure
rendering. However, this created situations where the tree had to be
'corrected' by inserting missing "first"
. This code was complex and resulted
in some unexpected operations having the side effect of modifying the tree.
The "first"
atoms are now created during parsing and are present in editable
and non-editable atom trees.
Refactoring of Atom classes
This is an internal change that does not affect the public API.
Each 'kind' of atom (fraction, extensible symbol, boxed expression, etc...) is
now represented by a separate class extending the Atom
base class (for
example GenfracAtom
). Each of those classes have a render()
method that
generates a set of DOM virtual nodes representing the Atom and a serialize()
method which generates a LaTeX string representing the atom.
Previously the handling of the different kind of atoms was done procedurally and all over the code base. The core code is now much smaller and easier to read, while the specialized code specific to each kind of atom is grouped in their respective classes.
Unit testing using Jest snapshot
Rewrote the unit tests to use Jest snapshots for more comprehensive validation.
Changelog
0.59.0 2020-11-04
Changelog
0.58.0 2020-10-11
#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.
x=sin
→ x\sin
instead of x=\sin
\xrightarrow
were incorrectly treated
as if they had an invisible boundary, resulting in the cursor being positioned
incorrectly when navigating with the keyboard.