Comparing version 0.101.2 to 0.102.0
@@ -1,2 +0,2 @@ | ||
/* 0.101.2 */ import type { Keys } from './types-utils'; | ||
/* 0.102.0 */ import type { Keys } from './types-utils'; | ||
import type { InsertOptions, ParseMode, Style, TabularEnvironment } from './core-types'; | ||
@@ -27,4 +27,19 @@ import type { Mathfield, Model } from './mathfield'; | ||
* | ||
* Commands return true if they resulted in a dirty state. | ||
* @category Commands | ||
* Some commands require an argument, for example to insert a character: | ||
* | ||
* ```ts | ||
* mf.executeCommand('insert("x")' }); | ||
* ``` | ||
* | ||
* The argument can be specified in parentheses after the command name, or | ||
* using an array: | ||
* | ||
* ```ts | ||
* mf.executeCommand(['switchMode', 'latex']); | ||
* // Same as mf.executeCommand('switchMode("latex")'); | ||
* ``` | ||
* | ||
* Commands (and `executeCommand()`) return true if they resulted in a dirty | ||
* state. | ||
* @category Editing Commands | ||
* @command executeCommand | ||
@@ -43,4 +58,6 @@ */ | ||
* Perform a command and include interactive feedback such as sound and | ||
* haptic feedback. This is useful to simulate user interaction, | ||
* for example for commands from the virtual keyboard | ||
* haptic feedback. | ||
* | ||
* This is useful to simulate user interaction, for example for commands | ||
* from the virtual keyboard | ||
*/ | ||
@@ -314,3 +331,3 @@ performWithFeedback: (mathfield: Mathfield, command: string) => boolean; | ||
} | ||
/** @category Commands */ | ||
/** @category Editing Commands */ | ||
export type Selector = Keys<Commands>; |
@@ -1,2 +0,2 @@ | ||
/* 0.101.2 */ export type MathstyleName = 'displaystyle' | 'textstyle' | 'scriptstyle' | 'scriptscriptstyle'; | ||
/* 0.102.0 */ export type MathstyleName = 'displaystyle' | 'textstyle' | 'scriptstyle' | 'scriptscriptstyle'; | ||
/** @internal */ | ||
@@ -119,3 +119,3 @@ export type ArgumentType = ParseMode | ('bbox' | 'colspec' | 'delim' | 'value' | 'rest' | 'string' | 'balanced-string' | 'expression' | 'auto'); | ||
* * {@linkcode MacroDictionary} | ||
* * {@link mathfield/guides/macros/|Macros Guide} | ||
* * {@link //mathfield/guides/macros/} | ||
* | ||
@@ -122,0 +122,0 @@ * @category Macros |
@@ -1,2 +0,2 @@ | ||
/* 0.101.2 */ import type { Selector } from './commands'; | ||
/* 0.102.0 */ import type { Selector } from './commands'; | ||
import type { Expression, LatexSyntaxError, MacroDictionary, Offset, ParseMode, Registers, Style, Selection, Range, OutputFormat, ElementInfo, InsertOptions } from './core-types'; | ||
@@ -763,6 +763,5 @@ import type { InsertStyleHook, Mathfield } from './mathfield'; | ||
/** | ||
* @inheritDoc _Mathfield#getPromptValue | ||
* Return the content of the `\placeholder{}` command with the `placeholderId` | ||
* @category Prompts */ | ||
getPromptValue(placeholderId: string, format?: OutputFormat): string; | ||
/** {@inheritDoc _Mathfield.setPromptValue} */ | ||
/** @category Prompts */ | ||
@@ -837,3 +836,19 @@ setPromptValue(id: string, content: string, insertOptions: Omit<InsertOptions, 'insertionMode'>): void; | ||
/** | ||
* @inheritDoc _Mathfield.executeCommand | ||
* @category Commands | ||
* Execute a {@linkcode Commands|command} defined by a selector. | ||
* ```javascript | ||
* mfe.executeCommand('add-column-after'); | ||
* mfe.executeCommand(['switch-mode', 'math']); | ||
* ``` | ||
* | ||
* @param selector - A selector, or an array whose first element | ||
* is a selector, and whose subsequent elements are arguments to the selector. | ||
* | ||
* Selectors can be passed either in camelCase or kebab-case. | ||
* | ||
* ```javascript | ||
* // Both calls do the same thing | ||
* mfe.executeCommand('selectAll'); | ||
* mfe.executeCommand('select-all'); | ||
* ``` | ||
*/ | ||
@@ -844,4 +859,15 @@ executeCommand(selector: Selector): boolean; | ||
/** | ||
* @inheritDoc _Mathfield.getValue */ | ||
/** @category Accessing and changing the content | ||
* Return a textual representation of the content of the mathfield. | ||
* | ||
* @param format - The format of the result. If using `math-json` | ||
* the Compute Engine library must be loaded, for example with: | ||
* | ||
* ```js | ||
import "https://unpkg.com/@cortex-js/compute-engine?module"; | ||
``` | ||
* | ||
* | ||
* **Default:** `"latex"` | ||
* | ||
* @category Accessing and changing the content | ||
*/ | ||
@@ -853,3 +879,5 @@ getValue(format?: OutputFormat): string; | ||
/** | ||
* @inheritDoc _Mathfield.setValue | ||
* Set the content of the mathfield to the text interpreted as a | ||
* LaTeX expression. | ||
* | ||
* @category Accessing and changing the content | ||
@@ -859,3 +887,4 @@ */ | ||
/** | ||
* @inheritDoc _Mathfield.hasFocus | ||
* Return true if the mathfield is currently focused (responds to keyboard | ||
* input). | ||
* | ||
@@ -887,3 +916,9 @@ * @category Focus | ||
/** | ||
* @inheritDoc _Mathfield.insert | ||
* Insert a block of text at the current insertion point. | ||
* | ||
* This method can be called explicitly or invoked as a selector with | ||
* `executeCommand("insert")`. | ||
* | ||
* After the insertion, the selection will be set according to the | ||
* `options.selectionMode`. | ||
@@ -894,4 +929,23 @@ * @category Accessing and changing the content | ||
/** | ||
* @inheritDoc _Mathfield.applyStyle | ||
* Update the style (color, bold, italic, etc...) of the selection or sets | ||
* the style to be applied to future input. | ||
* | ||
* If there is no selection and no range is specified, the style will | ||
* apply to the next character typed. | ||
* | ||
* If a range is specified, the style is applied to the range, otherwise, | ||
* if there is a selection, the style is applied to the selection. | ||
* | ||
* If the operation is `"toggle"` and the range already has this style, | ||
* remove it. If the range | ||
* has the style partially applied (i.e. only some sections), remove it from | ||
* those sections, and apply it to the entire range. | ||
* | ||
* If the operation is `"set"`, the style is applied to the range, | ||
* whether it already has the style or not. | ||
* | ||
* The default operation is `"set"`. | ||
* | ||
* | ||
* | ||
* @category Accessing and changing the content | ||
@@ -981,3 +1035,6 @@ */ | ||
/** @category Customization | ||
* @inheritDoc LayoutOptions.defaultMode | ||
* The mode of the element when it is empty: | ||
* - `"math"`: equivalent to `\displaystyle` (display math mode) | ||
* - `"inline-math"`: equivalent to `\inlinestyle` (inline math mode) | ||
* - `"text"`: text mode | ||
*/ | ||
@@ -987,3 +1044,22 @@ get defaultMode(): 'inline-math' | 'math' | 'text'; | ||
/** @category Customization | ||
* @inheritDoc LayoutOptions.macros | ||
* A dictionary of LaTeX macros to be used to interpret and render the content. | ||
* | ||
* For example, to add a new macro to the default macro dictionary: | ||
* | ||
```javascript | ||
mf.macros = { | ||
...mf.macros, | ||
smallfrac: '^{#1}\\!\\!/\\!_{#2}', | ||
}; | ||
``` | ||
* | ||
* Note that `...mf.macros` is used to keep the existing macros and add to | ||
* them. | ||
* Otherwise, all the macros are replaced with the new definition. | ||
* | ||
* The code above will support the following notation: | ||
* | ||
```tex | ||
\smallfrac{5}{16} | ||
``` | ||
*/ | ||
@@ -998,59 +1074,199 @@ get macros(): Readonly<MacroDictionary>; | ||
/** @category Customization | ||
* Map a color name as used in commands such as `\textcolor{}{}` or | ||
* `\colorbox{}{}` to a CSS color value. | ||
* | ||
* Use this option to override the standard mapping of colors such as "yellow" | ||
* or "red". | ||
* | ||
* If the name is not one you expected, return `undefined` and the default | ||
* color mapping will be applied. | ||
* | ||
* If a `backgroundColorMap()` function is not provided, the `colorMap()` | ||
* function will be used instead. | ||
* | ||
* If `colorMap()` is not provided, default color mappings are applied. | ||
* | ||
* The following color names have been optimized for a legible foreground | ||
* and background values, and are recommended: | ||
* - `red`, `orange`, `yellow`, `lime`, `green`, `teal`, `blue`, `indigo`, | ||
* `purple`, `magenta`, `black`, `dark-grey`, `grey`, `light-grey`, `white` | ||
*/ | ||
/** {@inheritDoc LayoutOptions.colorMap} */ | ||
get colorMap(): (name: string) => string | undefined; | ||
set colorMap(value: (name: string) => string | undefined); | ||
/** @category Customization */ | ||
/** {@inheritDoc LayoutOptions.backgroundColorMap} */ | ||
get backgroundColorMap(): (name: string) => string | undefined; | ||
set backgroundColorMap(value: (name: string) => string | undefined); | ||
/** @category Customization */ | ||
/** {@inheritDoc LayoutOptions.letterShapeStyle} */ | ||
/** @category Customization | ||
* Control the letter shape style: | ||
| `letterShapeStyle` | xyz | ABC | αβɣ | ΓΔΘ | | ||
| ------------------ | --- | --- | --- | --- | | ||
| `iso` | it | it | it | it | | ||
| `tex` | it | it | it | up | | ||
| `french` | it | up | up | up | | ||
| `upright` | up | up | up | up | | ||
(it) = italic (up) = upright | ||
* The default letter shape style is `auto`, which indicates that `french` | ||
* should be used if the locale is "french", and `tex` otherwise. | ||
* | ||
* **Historical Note** | ||
* | ||
* Where do the "french" rules come from? The | ||
* TeX standard font, Computer Modern, is based on Monotype 155M, itself | ||
* based on the Porson greek font which was one of the most widely used | ||
* Greek fonts in english-speaking countries. This font had upright | ||
* capitals, but slanted lowercase. In France, the traditional font for | ||
* greek was Didot, which has both upright capitals and lowercase. | ||
* | ||
* As for roman uppercase, they are recommended by "Lexique des règles | ||
* typographiques en usage à l’Imprimerie Nationale". It should be noted | ||
* that this convention is not universally followed. | ||
*/ | ||
get letterShapeStyle(): 'auto' | 'tex' | 'iso' | 'french' | 'upright'; | ||
set letterShapeStyle(value: 'auto' | 'tex' | 'iso' | 'french' | 'upright'); | ||
/** @category Customization */ | ||
/** {@inheritDoc LayoutOptions.minFontScale} */ | ||
/** @category Customization | ||
* Set the minimum relative font size for nested superscripts and fractions. The value | ||
* should be a number between `0` and `1`. The size is in releative `em` units relative to the | ||
* font size of the `math-field` element. Specifying a value of `0` allows the `math-field` | ||
* to use its default sizing logic. | ||
* | ||
* **Default**: `0` | ||
*/ | ||
get minFontScale(): number; | ||
set minFontScale(value: number); | ||
/** @category Customization */ | ||
/** {@inheritDoc LayoutOptions.maxMatrixCols} */ | ||
/** @category Customization | ||
* Sets the maximum number of columns for the matrix environment. The default is | ||
* 10 columns to match the behavior of the amsmath matrix environment. | ||
* **Default**: `10` | ||
*/ | ||
get maxMatrixCols(): number; | ||
set maxMatrixCols(value: number); | ||
/** @category Customization */ | ||
/** {@inheritDoc EditingOptions.smartMode}*/ | ||
/** @category Customization | ||
* When `true`, during text input the field will switch automatically between | ||
* 'math' and 'text' mode depending on what is typed and the context of the | ||
* formula. If necessary, what was previously typed will be 'fixed' to | ||
* account for the new info. | ||
* | ||
* For example, when typing "if x >0": | ||
* | ||
* | Type | Interpretation | | ||
* |---:|:---| | ||
* | `i` | math mode, imaginary unit | | ||
* | `if` | text mode, english word "if" | | ||
* | `if x` | all in text mode, maybe the next word is xylophone? | | ||
* | `if x >` | "if" stays in text mode, but now "x >" is in math mode | | ||
* | `if x > 0` | "if" in text mode, "x > 0" in math mode | | ||
* | ||
* **Default**: `false` | ||
* | ||
* Manually switching mode (by typing `alt/option+=`) will temporarily turn | ||
* off smart mode. | ||
* | ||
* | ||
* **Examples** | ||
* | ||
* - `slope = rise/run` | ||
* - `If x > 0, then f(x) = sin(x)` | ||
* - `x^2 + sin (x) when x > 0` | ||
* - `When x<0, x^{2n+1}<0` | ||
* - `Graph x^2 -x+3 =0 for 0<=x<=5` | ||
* - `Divide by x-3 and then add x^2-1 to both sides` | ||
* - `Given g(x) = 4x – 3, when does g(x)=0?` | ||
* - `Let D be the set {(x,y)|0<=x<=1 and 0<=y<=x}` | ||
* - `\int\_{the unit square} f(x,y) dx dy` | ||
* - `For all n in NN` | ||
*/ | ||
get smartMode(): boolean; | ||
set smartMode(value: boolean); | ||
/** @category Customization */ | ||
/** {@inheritDoc EditingOptions.smartFence}*/ | ||
/** @category Customization | ||
* | ||
* When `true` and an open fence is entered via `typedText()` it will | ||
* generate a contextually appropriate markup, for example using | ||
* `\left...\right` if applicable. | ||
* | ||
* When `false`, the literal value of the character will be inserted instead. | ||
*/ | ||
get smartFence(): boolean; | ||
set smartFence(value: boolean); | ||
/** @category Customization */ | ||
/** {@inheritDoc EditingOptions.smartSuperscript} */ | ||
/** @category Customization | ||
* When `true` and a digit is entered in an empty superscript, the cursor | ||
* leaps automatically out of the superscript. This makes entry of common | ||
* polynomials easier and faster. If entering other characters (for example | ||
* "n+1") the navigation out of the superscript must be done manually (by | ||
* using the cursor keys or the spacebar to leap to the next insertion | ||
* point). | ||
* | ||
* When `false`, the navigation out of the superscript must always be done | ||
* manually. | ||
*/ | ||
get smartSuperscript(): boolean; | ||
set smartSuperscript(value: boolean); | ||
/** @category Customization */ | ||
/** {@inheritDoc EditingOptions.scriptDepth} */ | ||
/** @category Customization | ||
* This option controls how many levels of subscript/superscript can be entered. For | ||
* example, if `scriptDepth` is "1", there can be one level of superscript or | ||
* subscript. Attempting to enter a superscript while inside a superscript will | ||
* be rejected. Setting a value of 0 will prevent entry of any superscript or | ||
* subscript (but not limits for sum, integrals, etc...) | ||
* | ||
* This can make it easier to enter equations that fit what's expected for the | ||
* domain where the mathfield is used. | ||
* | ||
* To control the depth of superscript and subscript independently, provide an | ||
* array: the first element indicate the maximum depth for subscript and the | ||
* second element the depth of superscript. Thus, a value of `[0, 1]` would | ||
* suppress the entry of subscripts, and allow one level of superscripts. | ||
*/ | ||
get scriptDepth(): number | [number, number]; | ||
set scriptDepth(value: number | [number, number]); | ||
/** @category Customization */ | ||
/** {@inheritDoc EditingOptions.removeExtraneousParentheses} */ | ||
/** @category Customization | ||
* If `true`, extra parentheses around a numerator or denominator are | ||
* removed automatically. | ||
* | ||
* **Default**: `true` | ||
*/ | ||
get removeExtraneousParentheses(): boolean; | ||
set removeExtraneousParentheses(value: boolean); | ||
/** @category Customization */ | ||
/** {@inheritDoc EditingOptions.mathModeSpace} */ | ||
/** @category Customization | ||
* The LaTeX string to insert when the spacebar is pressed (on the physical or | ||
* virtual keyboard). | ||
* | ||
* Use `"\;"` for a thick space, `"\:"` for a medium space, `"\,"` for a | ||
* thin space. | ||
* | ||
* Do not use `" "` (a regular space), as whitespace is skipped by LaTeX | ||
* so this will do nothing. | ||
* | ||
* **Default**: `""` (empty string) | ||
*/ | ||
get mathModeSpace(): string; | ||
set mathModeSpace(value: string); | ||
/** @category Customization */ | ||
/** {@inheritDoc EditingOptions.placeholderSymbol} */ | ||
/** @category Customization | ||
* The symbol used to represent a placeholder in an expression. | ||
* | ||
* **Default**: `▢` `U+25A2 WHITE SQUARE WITH ROUNDED CORNERS` | ||
*/ | ||
get placeholderSymbol(): string; | ||
set placeholderSymbol(value: string); | ||
/** @category Customization | ||
* A LaTeX string displayed inside the mathfield when there is no content. | ||
*/ | ||
get placeholder(): string; | ||
set placeholder(value: string); | ||
/** @category Customization */ | ||
/** {@inheritDoc EditingOptions.popoverPolicy} */ | ||
/** @category Customization | ||
* If `"auto"` a popover with suggestions may be displayed when a LaTeX | ||
* command is input. | ||
* | ||
* **Default**: `"auto"` | ||
*/ | ||
get popoverPolicy(): 'auto' | 'off'; | ||
set popoverPolicy(value: 'auto' | 'off'); | ||
/** | ||
* @category Customization */ | ||
/** {@inheritDoc EditingOptions.environmentPopoverPolicy} */ | ||
* @category Customization | ||
* If `"auto"` a popover with commands to edit an environment (matrix) | ||
* is displayed when the virtual keyboard is displayed. | ||
* | ||
* **Default**: `"auto"` | ||
*/ | ||
get environmentPopoverPolicy(): 'auto' | 'off' | 'on'; | ||
@@ -1067,11 +1283,31 @@ set environmentPopoverPolicy(value: 'auto' | 'off' | 'on'); | ||
*/ | ||
/** * {@inheritDoc EditingOptions.mathVirtualKeyboardPolicy} */ | ||
get mathVirtualKeyboardPolicy(): VirtualKeyboardPolicy; | ||
set mathVirtualKeyboardPolicy(value: VirtualKeyboardPolicy); | ||
/** @category Customization */ | ||
/** * {@inheritDoc EditingOptions.inlineShortcuts} */ | ||
/** @category Customization | ||
* The keys of this object literal indicate the sequence of characters | ||
* that will trigger an inline shortcut. | ||
*/ | ||
get inlineShortcuts(): Readonly<InlineShortcutDefinitions>; | ||
set inlineShortcuts(value: InlineShortcutDefinitions); | ||
/** @category Customization | ||
* {@inheritDoc EditingOptions.inlineShortcutTimeout} | ||
* Maximum time, in milliseconds, between consecutive characters for them to be | ||
* considered part of the same shortcut sequence. | ||
* | ||
* A value of 0 is the same as infinity: any consecutive character will be | ||
* candidate for an inline shortcut, regardless of the interval between this | ||
* character and the previous one. | ||
* | ||
* A value of 750 will indicate that the maximum interval between two | ||
* characters to be considered part of the same inline shortcut sequence is | ||
* 3/4 of a second. | ||
* | ||
* This is useful to enter "+-" as a sequence of two characters, while also | ||
* supporting the "±" shortcut with the same sequence. | ||
* | ||
* The first result can be entered by pausing slightly between the first and | ||
* second character if this option is set to a value of 250 or so. | ||
* | ||
* Note that some operations, such as clicking to change the selection, or | ||
* losing the focus on the mathfield, will automatically timeout the | ||
* shortcuts. | ||
*/ | ||
@@ -1081,7 +1317,5 @@ get inlineShortcutTimeout(): number; | ||
/** @category Customization */ | ||
/** * {@inheritDoc EditingOptions.keybindings} */ | ||
get keybindings(): Readonly<Keybinding[]>; | ||
set keybindings(value: Readonly<Keybinding[]>); | ||
/** @category Hooks | ||
* @inheritDoc _MathfieldHooks.onInsertStyle | ||
*/ | ||
@@ -1091,3 +1325,9 @@ get onInsertStyle(): InsertStyleHook | undefined | null; | ||
/** @category Hooks | ||
* @inheritDoc _MathfieldHooks.onInlineShortcut | ||
* A hook invoked when a string of characters that could be | ||
* interpreted as shortcut has been typed. | ||
* | ||
* If not a special shortcut, return the empty string `""`. | ||
* | ||
* Use this handler to detect multi character symbols, and return them wrapped appropriately, | ||
* for example `\mathrm{${symbol}}`. | ||
*/ | ||
@@ -1097,3 +1337,6 @@ get onInlineShortcut(): (sender: Mathfield, symbol: string) => string; | ||
/** @category Hooks | ||
* @inheritDoc _MathfieldHooks.onScrollIntoView | ||
* A hook invoked when scrolling the mathfield into view is necessary. | ||
* | ||
* Use when scrolling the page would not solve the problem, e.g. | ||
* when the mathfield is in another div that has scrollable content. | ||
*/ | ||
@@ -1103,3 +1346,17 @@ get onScrollIntoView(): ((sender: Mathfield) => void) | null; | ||
/** @category Hooks | ||
* @inheritDoc _MathfieldHooks.onExport | ||
* This hook is invoked when the user has requested to export the content | ||
* of the mathfield, for example when pressing ctrl/command+C. | ||
* | ||
* This hook should return as a string what should be exported. | ||
* | ||
* The `range` argument indicates which portion of the mathfield should be | ||
* exported. It is not always equal to the current selection, but it can | ||
* be used to export a format other than LaTeX. | ||
* | ||
* By default this is: | ||
* | ||
* ```js | ||
* return `\\begin{equation*}${latex}\\end{equation*}`; | ||
* ``` | ||
* | ||
*/ | ||
@@ -1106,0 +1363,0 @@ get onExport(): (from: Mathfield, latex: string, range: Range) => string; |
@@ -1,2 +0,2 @@ | ||
/* 0.101.2 */ import type { Selector } from './commands'; | ||
/* 0.102.0 */ import type { Selector } from './commands'; | ||
import type { ApplyStyleOptions, InsertOptions, Offset, OutputFormat, Style, Range, Selection } from './core-types'; | ||
@@ -9,35 +9,3 @@ export type InsertStyleHook = (sender: Mathfield, at: Offset, info: { | ||
export interface Mathfield { | ||
/** | ||
* Execute a {@linkcode Commands|command} defined by a selector. | ||
* ```javascript | ||
* mfe.executeCommand('add-column-after'); | ||
* mfe.executeCommand(['switch-mode', 'math']); | ||
* ``` | ||
* | ||
* @param command - A selector, or an array whose first element | ||
* is a selector, and whose subsequent elements are arguments to the selector. | ||
* | ||
* Selectors can be passed either in camelCase or kebab-case. | ||
* | ||
* ```javascript | ||
* // Both calls do the same thing | ||
* mfe.executeCommand('selectAll'); | ||
* mfe.executeCommand('select-all'); | ||
* ``` | ||
*/ | ||
executeCommand(command: Selector | [Selector, ...any[]]): boolean; | ||
/** | ||
* Return a textual representation of the content of the mathfield. | ||
* | ||
* @param format - The format of the result. If using `math-json` | ||
* the Compute Engine library must be loaded, for example with: | ||
* | ||
* ```js | ||
import "https://unpkg.com/@cortex-js/compute-engine?module"; | ||
``` | ||
* | ||
* | ||
* **Default:** `"latex"` | ||
* | ||
*/ | ||
getValue(format?: OutputFormat): string; | ||
@@ -51,52 +19,8 @@ /** Return the value of the mathfield from `start` to `end` */ | ||
select(): void; | ||
/** | ||
* Set the content of the mathfield to the text interpreted as a | ||
* LaTeX expression. | ||
* | ||
*/ | ||
setValue(latex?: string, options?: InsertOptions): void; | ||
/** | ||
* Insert a block of text at the current insertion point. | ||
* | ||
* This method can be called explicitly or invoked as a selector with | ||
* `executeCommand("insert")`. | ||
* | ||
* After the insertion, the selection will be set according to the | ||
* `options.selectionMode`. | ||
* | ||
*/ | ||
insert(s: string, options?: InsertOptions): boolean; | ||
/** | ||
* Return true if the mathfield is currently focused (responds to keyboard | ||
* input). | ||
* | ||
*/ | ||
hasFocus(): boolean; | ||
focus?(): void; | ||
blur?(): void; | ||
/** | ||
* Update the style (color, bold, italic, etc...) of the selection or sets | ||
* the style to be applied to future input. | ||
* | ||
* If there is no selection and no range is specified, the style will | ||
* apply to the next character typed. | ||
* | ||
* If a range is specified, the style is applied to the range, otherwise, | ||
* if there is a selection, the style is applied to the selection. | ||
* | ||
* If the operation is `"toggle"` and the range already has this style, | ||
* remove it. If the range | ||
* has the style partially applied (i.e. only some sections), remove it from | ||
* those sections, and apply it to the entire range. | ||
* | ||
* If the operation is `"set"`, the style is applied to the range, | ||
* whether it already has the style or not. | ||
* | ||
* The default operation is `"set"`. | ||
* | ||
*/ | ||
applyStyle(style: Style, options?: ApplyStyleOptions): void; | ||
/** | ||
* Return the content of the `\placeholder{}` command with the `placeholderId` | ||
*/ | ||
getPromptValue(placeholderId: string, format?: OutputFormat): string; | ||
@@ -103,0 +27,0 @@ getPrompts(filter?: { |
@@ -1,2 +0,2 @@ | ||
/* 0.101.2 */ /** | ||
/* 0.102.0 */ /** | ||
* Server-side rendering exports. | ||
@@ -38,3 +38,3 @@ * | ||
* | ||
* @param options.mathstyle If `"displaystyle"` the "display" mode of TeX | ||
* @param options.defaultMode If `"displaystyle"` the "display" mode of TeX | ||
* is used to typeset the formula, which is most appropriate for formulas that are | ||
@@ -41,0 +41,0 @@ * displayed in a standalone block. |
@@ -1,2 +0,2 @@ | ||
/* 0.101.2 */ /** | ||
/* 0.102.0 */ /** | ||
* | ||
@@ -23,3 +23,3 @@ * Importing this package in a web page will make the `<math-field>` custom | ||
* @packageDocumentation Mathfield API Reference | ||
* @version 0.101.2 | ||
* @version 0.102.0 | ||
* | ||
@@ -26,0 +26,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
/* 0.101.2 */ import type { Mathfield, InsertStyleHook } from './mathfield'; | ||
/* 0.102.0 */ import type { Mathfield, InsertStyleHook } from './mathfield'; | ||
import type { Selector } from './commands'; | ||
@@ -183,37 +183,5 @@ import type { ParseMode, MacroDictionary, Registers, Range } from './core-types'; | ||
export interface MathfieldHooks { | ||
/** | ||
* A hook invoked when a string of characters that could be | ||
* interpreted as shortcut has been typed. | ||
* | ||
* If not a special shortcut, return the empty string `""`. | ||
* | ||
* Use this handler to detect multi character symbols, and return them wrapped appropriately, | ||
* for example `\mathrm{${symbol}}`. | ||
*/ | ||
onInlineShortcut: (sender: Mathfield, symbol: string) => string; | ||
onInsertStyle: InsertStyleHook | undefined | null; | ||
/** | ||
* A hook invoked when a scrolling the mathfield into view is necessary. | ||
* | ||
* Use when scrolling the page would not solve the problem, e.g. | ||
* when the mathfield is in another div that has scrollable content. | ||
*/ | ||
onScrollIntoView: ((sender: Mathfield) => void) | null; | ||
/** | ||
* This hook is invoked when the user has requested to export the content | ||
* of the mathfield, for example when pressing ctrl/command+C. | ||
* | ||
* This hook should return as a string what should be exported. | ||
* | ||
* The `range` argument indicates which portion of the mathfield should be | ||
* exported. It is not always equal to the current selection, but it can | ||
* be used to export a format other than LaTeX. | ||
* | ||
* By default this is: | ||
* | ||
* ```js | ||
* return `\\begin{equation*}${latex}\\end{equation*}`; | ||
* ``` | ||
* | ||
*/ | ||
onExport: (from: Mathfield, latex: string, range: Range) => string; | ||
@@ -235,30 +203,3 @@ } | ||
export type InlineShortcutsOptions = { | ||
/** | ||
* The keys of this object literal indicate the sequence of characters | ||
* that will trigger an inline shortcut. | ||
* | ||
*/ | ||
inlineShortcuts: InlineShortcutDefinitions; | ||
/** | ||
* Maximum time, in milliseconds, between consecutive characters for them to be | ||
* considered part of the same shortcut sequence. | ||
* | ||
* A value of 0 is the same as infinity: any consecutive character will be | ||
* candidate for an inline shortcut, regardless of the interval between this | ||
* character and the previous one. | ||
* | ||
* A value of 750 will indicate that the maximum interval between two | ||
* characters to be considered part of the same inline shortcut sequence is | ||
* 3/4 of a second. | ||
* | ||
* This is useful to enter "+-" as a sequence of two characters, while also | ||
* supporting the "±" shortcut with the same sequence. | ||
* | ||
* The first result can be entered by pausing slightly between the first and | ||
* second character if this option is set to a value of 250 or so. | ||
* | ||
* Note that some operations, such as clicking to change the selection, or | ||
* losing the focus on the mathfield, will automatically timeout the | ||
* shortcuts. | ||
*/ | ||
inlineShortcutTimeout: number; | ||
@@ -274,82 +215,6 @@ }; | ||
readOnly: boolean; | ||
/** | ||
* When `true`, during text input the field will switch automatically between | ||
* 'math' and 'text' mode depending on what is typed and the context of the | ||
* formula. If necessary, what was previously typed will be 'fixed' to | ||
* account for the new info. | ||
* | ||
* For example, when typing "if x >0": | ||
* | ||
* | Type | Interpretation | | ||
* |---:|:---| | ||
* | `i` | math mode, imaginary unit | | ||
* | `if` | text mode, english word "if" | | ||
* | `if x` | all in text mode, maybe the next word is xylophone? | | ||
* | `if x >` | "if" stays in text mode, but now "x >" is in math mode | | ||
* | `if x > 0` | "if" in text mode, "x > 0" in math mode | | ||
* | ||
* **Default**: `false` | ||
* | ||
* Manually switching mode (by typing `alt/option+=`) will temporarily turn | ||
* off smart mode. | ||
* | ||
* | ||
* **Examples** | ||
* | ||
* - `slope = rise/run` | ||
* - `If x > 0, then f(x) = sin(x)` | ||
* - `x^2 + sin (x) when x > 0` | ||
* - `When x<0, x^{2n+1}<0` | ||
* - `Graph x^2 -x+3 =0 for 0<=x<=5` | ||
* - `Divide by x-3 and then add x^2-1 to both sides` | ||
* - `Given g(x) = 4x – 3, when does g(x)=0?` | ||
* - `Let D be the set {(x,y)|0<=x<=1 and 0<=y<=x}` | ||
* - `\int\_{the unit square} f(x,y) dx dy` | ||
* - `For all n in NN` | ||
* | ||
*/ | ||
smartMode: boolean; | ||
/** | ||
* When `true` and an open fence is entered via `typedText()` it will | ||
* generate a contextually appropriate markup, for example using | ||
* `\left...\right` if applicable. | ||
* | ||
* When `false`, the literal value of the character will be inserted instead. | ||
*/ | ||
smartFence: boolean; | ||
/** | ||
* When `true` and a digit is entered in an empty superscript, the cursor | ||
* leaps automatically out of the superscript. This makes entry of common | ||
* polynomials easier and faster. If entering other characters (for example | ||
* "n+1") the navigation out of the superscript must be done manually (by | ||
* using the cursor keys or the spacebar to leap to the next insertion | ||
* point). | ||
* | ||
* When `false`, the navigation out of the superscript must always be done | ||
* manually. | ||
* | ||
*/ | ||
smartSuperscript: boolean; | ||
/** | ||
* This option controls how many levels of subscript/superscript can be entered. For | ||
* example, if `scriptDepth` is "1", there can be one level of superscript or | ||
* subscript. Attempting to enter a superscript while inside a superscript will | ||
* be rejected. Setting a value of 0 will prevent entry of any superscript or | ||
* subscript (but not limits for sum, integrals, etc...) | ||
* | ||
* This can make it easier to enter equations that fit what's expected for the | ||
* domain where the mathfield is used. | ||
* | ||
* To control the depth of superscript and subscript independently, provide an | ||
* array: the first element indicate the maximum depth for subscript and the | ||
* second element the depth of superscript. Thus, a value of `[0, 1]` would | ||
* suppress the entry of subscripts, and allow one level of superscripts. | ||
*/ | ||
scriptDepth: number | [number, number]; | ||
/** | ||
* If `true`, extra parentheses around a numerator or denominator are | ||
* removed automatically. | ||
* | ||
* **Default**: `true` | ||
*/ | ||
removeExtraneousParentheses: boolean; | ||
@@ -366,38 +231,6 @@ /** | ||
isImplicitFunction: (name: string) => boolean; | ||
/** | ||
* The LaTeX string to insert when the spacebar is pressed (on the physical or | ||
* virtual keyboard). | ||
* | ||
* Use `"\;"` for a thick space, `"\:"` for a medium space, `"\,"` for a | ||
* thin space. | ||
* | ||
* Do not use `" "` (a regular space), as whitespace is skipped by LaTeX | ||
* so this will do nothing. | ||
* | ||
* **Default**: `""` (empty string) | ||
*/ | ||
mathModeSpace: string; | ||
/** | ||
* The symbol used to represent a placeholder in an expression. | ||
* | ||
* **Default**: `▢` `U+25A2 WHITE SQUARE WITH ROUNDED CORNERS` | ||
*/ | ||
placeholderSymbol: string; | ||
/** | ||
* A LaTeX string displayed inside the mathfield when there is no content. | ||
*/ | ||
contentPlaceholder: string; | ||
/** | ||
* If `"auto"` a popover with suggestions may be displayed when a LaTeX | ||
* command is input. | ||
* | ||
* **Default**: `"auto"` | ||
*/ | ||
popoverPolicy: 'auto' | 'off'; | ||
/** | ||
* If `"auto"` a popover with commands to edit an environment (matrix) | ||
* is displayed when the virtual keyboard is displayed. | ||
* | ||
* **Default**: `"auto"` | ||
*/ | ||
environmentPopoverPolicy: 'auto' | 'on' | 'off'; | ||
@@ -408,31 +241,3 @@ mathVirtualKeyboardPolicy: 'auto' | 'manual' | 'sandboxed'; | ||
export type LayoutOptions = { | ||
/** | ||
* The mode of the element when it is empty: | ||
* - `"math"`: equivalent to `\displaystyle` (display math mode) | ||
* - `"inline-math"`: equivalent to `\inlinestyle` (inline math mode) | ||
* - `"text"`: text mode | ||
*/ | ||
defaultMode: 'inline-math' | 'math' | 'text'; | ||
/** | ||
* A dictionary of LaTeX macros to be used to interpret and render the content. | ||
* | ||
* For example, to add a new macro to the default macro dictionary: | ||
* | ||
```javascript | ||
mf.macros = { | ||
...mf.macros, | ||
smallfrac: '^{#1}\\!\\!/\\!_{#2}', | ||
}; | ||
``` | ||
* | ||
* Note that `...mf.macros` is used to keep the existing macros and add to | ||
* them. | ||
* Otherwise, all the macros are replaced with the new definition. | ||
* | ||
* The code above will support the following notation: | ||
* | ||
```tex | ||
\smallfrac{5}{16} | ||
``` | ||
*/ | ||
macros: MacroDictionary; | ||
@@ -443,67 +248,6 @@ /** | ||
registers: Registers; | ||
/** | ||
* Map a color name as used in commands such as `\textcolor{}{}` or | ||
* `\colorbox{}{}` to a CSS color value. | ||
* | ||
* Use this option to override the standard mapping of colors such as "yellow" | ||
* or "red". | ||
* | ||
* If the name is not one you expected, return `undefined` and the default | ||
* color mapping will be applied. | ||
* | ||
* If a `backgroundColorMap()` function is not provided, the `colorMap()` | ||
* function will be used instead. | ||
* | ||
* If `colorMap()` is not provided, default color mappings are applied. | ||
* | ||
* The following color names have been optimized for a legible foreground | ||
* and background values, and are recommended: | ||
* - `red`, `orange`, `yellow`, `lime`, `green`, `teal`, `blue`, `indigo`, | ||
* `purple`, `magenta`, `black`, `dark-grey`, `grey`, `light-grey`, `white` | ||
*/ | ||
colorMap: (name: string) => string | undefined; | ||
backgroundColorMap: (name: string) => string | undefined; | ||
/** | ||
* Control the letter shape style: | ||
| `letterShapeStyle` | xyz | ABC | αβɣ | ΓΔΘ | | ||
| ------------------ | --- | --- | --- | --- | | ||
| `iso` | it | it | it | it | | ||
| `tex` | it | it | it | up | | ||
| `french` | it | up | up | up | | ||
| `upright` | up | up | up | up | | ||
(it) = italic (up) = upright | ||
* The default letter shape style is `auto`, which indicates that `french` | ||
* should be used if the locale is "french", and `tex` otherwise. | ||
* | ||
* **Historical Note** | ||
* | ||
* Where do the "french" rules come from? The | ||
* TeX standard font, Computer Modern, is based on Monotype 155M, itself | ||
* based on the Porson greek font which was one of the most widely used | ||
* Greek fonts in english-speaking countries. This font had upright | ||
* capitals, but slanted lowercase. In France, the traditional font for | ||
* greek was Didot, which has both upright capitals and lowercase. | ||
* | ||
* As for roman uppercase, they are recommended by "Lexique des règles | ||
* typographiques en usage à l’Imprimerie Nationale". It should be noted | ||
* that this convention is not universally followed. | ||
*/ | ||
letterShapeStyle: 'auto' | 'tex' | 'iso' | 'french' | 'upright'; | ||
/** | ||
* Set the minimum relative font size for nested superscripts and fractions. The value | ||
* should be a number between `0` and `1`. The size is in releative `em` units relative to the | ||
* font size of the `math-field` element. Specifying a value of `0` allows the `math-field` | ||
* to use its default sizing logic. | ||
* | ||
* **Default**: `0` | ||
*/ | ||
minFontScale: number; | ||
/** | ||
* Sets the maximum number of columns for the matrix environment. The default is | ||
* 10 columns to match the behavior of the amsmath matrix environment. | ||
* **Default**: `10` | ||
*/ | ||
maxMatrixCols: number; | ||
@@ -510,0 +254,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
/* 0.101.2 */ /** | ||
/* 0.102.0 */ /** | ||
* @internal | ||
@@ -3,0 +3,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
/* 0.101.2 */ export type KeyboardModifiers = { | ||
/* 0.102.0 */ export type KeyboardModifiers = { | ||
alt: boolean; | ||
@@ -3,0 +3,0 @@ control: boolean; |
@@ -1,2 +0,2 @@ | ||
/* 0.101.2 */ import type { KeyboardModifiers } from './ui-events-types'; | ||
/* 0.102.0 */ import type { KeyboardModifiers } from './ui-events-types'; | ||
/** | ||
@@ -3,0 +3,0 @@ * The type of a menu item: |
@@ -1,2 +0,2 @@ | ||
/* 0.101.2 */ import type { Selector } from './commands'; | ||
/* 0.102.0 */ import type { Selector } from './commands'; | ||
import type { ParseMode, Style } from './core-types'; | ||
@@ -77,2 +77,4 @@ import type { OriginValidator } from './options'; | ||
layer: string; | ||
/** Open variants panel without long press and does not close automatically */ | ||
stickyVariantPanel: boolean; | ||
} | ||
@@ -261,3 +263,3 @@ /** | ||
/** | ||
* @category Commands | ||
* @category Editing Commands | ||
*/ | ||
@@ -264,0 +266,0 @@ export interface VirtualKeyboardCommands { |
{ | ||
"name": "mathlive", | ||
"version": "0.101.2", | ||
"version": "0.102.0", | ||
"description": "A web component for math input", | ||
@@ -49,4 +49,4 @@ "license": "MIT", | ||
"./sounds/*": "./dist/sounds/*", | ||
"./fonts/": "./dist/fonts/*", | ||
"./sounds/": "./dist/sounds/*" | ||
"./fonts/": "./dist/fonts/", | ||
"./sounds/": "./dist/sounds/" | ||
}, | ||
@@ -53,0 +53,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5420777
97953