Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "mathspeak" for screen reader usage. #33

Merged
merged 19 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
80682a8
Fix security vulnerabilities in npm dependencies.
drgrice1 Oct 29, 2024
10cf9b4
Convert the TNode byId property to a Map instead of a record.
drgrice1 Oct 30, 2024
2c30040
Turn on @typescript-eslint's strict type checking.
drgrice1 Oct 31, 2024
243eb7d
Remove mathquill basic.
drgrice1 Oct 31, 2024
db2639a
Fix some typing issues with the api.
drgrice1 Nov 10, 2024
68cfd7e
Dispense with the L, R enum.
drgrice1 Oct 31, 2024
de7fe53
Add the eslint mocha plugin for better linting of the unit tests.
drgrice1 Nov 3, 2024
fea75a2
Add mathspeak (essentially copied from Desmos' MathQuill fork)
drgrice1 Nov 1, 2024
d5fe9ce
Pull in a few more things from the desmos code.
drgrice1 Nov 4, 2024
8cf7e07
Change focus/blur behavior to be more like a native HTML text input.
drgrice1 Nov 5, 2024
378086f
Add an `otherDir` method for conveniently obtaining an opposite direc…
drgrice1 Nov 6, 2024
de8c2a5
Update the static math focus/blur behavior.
drgrice1 Nov 6, 2024
7af730c
Document options that have been added in docs/Config.md.
drgrice1 Nov 6, 2024
430460f
Make the "enter" handler actually work.
drgrice1 Nov 7, 2024
2c0bbd8
Improvements to focus/blur behavior with the preventBlur (now the blu…
drgrice1 Nov 7, 2024
7c4c92c
Fix static math fields with no mouse events not getting the textarea and
drgrice1 Nov 8, 2024
e443192
Switch to using SVGs for roots and brackets.
drgrice1 Nov 8, 2024
93d4f32
Add unit tests for the mathspeak of a math function.
drgrice1 Nov 8, 2024
9c73903
Bump the beta version so that this can be published.
drgrice1 Nov 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ Additionally you can run `npm run serve` which will automatically re-build and s
tests.

Then you can enter <http://localhost:9292/demo.html>, <http://localhost:9292/unit-test.html>,
<http://localhost:9292/visual-test.html>, <http://localhost:9292/input-test.html>,
<http://localhost:9292/basic-test.html>, or just <http://localhost:9292> in your browser to view the various available
pages.
<http://localhost:9292/visual-test.html>, <http://localhost:9292/input-test.html>, or just <http://localhost:9292> in
your browser to view the various available pages.

## Open-Source License

Expand Down
63 changes: 55 additions & 8 deletions docs/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The configuration options object is of the following form:

```js
{
spaceBehavesLikeTab: true,
enableSpaceNavigation: true,
leftRightIntoCmdGoes: 'up',
restrictMismatchedBrackets: true,
sumStartsWithNEquals: true,
Expand Down Expand Up @@ -35,10 +35,10 @@ Global defaults may be set with [`MQ.config(global_config)`](Api_Methods.md#mqco

The following configuration options are available.

### spacesBehavesLikeTab
### enableSpaceNavigation

If `spaceBehavesLikeTab` is true the keystrokes `{Shift-,}Spacebar` will behave like `{Shift-,}Tab` escaping from the
current block (as opposed to the default behavior of inserting a Space character).
If `enableSpaceNavigation` is true the keystrokes `{Shift-,}Spacebar` will behave like `{Shift-,}Escape` escaping from
the current block (as opposed to the default behavior of inserting a Space character).

### leftRightIntoCmdGoes

Expand Down Expand Up @@ -77,9 +77,9 @@ be exponentiated or subscripted. Prevents the especially confusing typo `x^^2`,
`charsThatBreakOutOfSupSub` takes a string of the chars that when typed, "break out" of superscripts and subscripts.

Normally, to get out of a superscript or subscript, a user has to navigate out of it with the directional keys, a mouse
click, tab, or Space if [`spaceBehavesLikeTab`](#spacesbehavesliketab) is true. For example, typing `x^2n+y` normally
results in the LaTeX `x^{2n+y}`. If you wanted to get the LaTeX `x^{2n}+y`, the user would have to manually move the
cursor out of the exponent.
click, or Space if `enableSpaceNavigation` is true. For example, typing `x^2n+y` normally results in the LaTeX
`x^{2n+y}`. If you wanted to get the LaTeX `x^{2n}+y`, the user would have to manually move the cursor out of the
exponent.

If this option was set to `'+-'`, `+` and `-` would "break out" of the exponent. This doesn't apply to the first
character in a superscript or subscript, so typing `x^-6` still results in `x^{-6}`. The downside to setting this option
Expand Down Expand Up @@ -122,6 +122,47 @@ Nested content in latex rendered during initialization or pasted into mathquill
Overwriting this may be useful for hacks like suppressing built-in virtual keyboards. It defaults to
`<textarea autocorrect=off .../>`.

### mouseEvents

If `mouseEvents` is true then mouse events are active for static math fieds. This is true by default.

### autoSubscriptNumerals

If `autoSubscriptNumerals` is true then a number typed after a letter will automatically be put into a subscript.

### typingSlashWritesDivisionSymbol

If `typingSlashWritesDivisionSymbol` true then typing a slash gives the division symbol instead of a live fraction.

### typingAsteriskWritesTimesSymbol

If `typingAsteriskWritesTimesSymbol` is true then typing an asterisk gives the times symbol instead of a `\cdot`.

### rootsAreExponents

If `rootsAreExponents` is true, then the text output of an nth root will be `x^(1/n)`. Otherwise it will be `root(n,x)`.

### logsChangeBase

If `logsChangeBase` is true then the text output for the logarithm with base b of x will be `log(x)/log(b)`. Otherwise
the output will be `logb(b,x)`. Note that this option does not affect base 10 output. That is always `log10(x)`.

### tabbable

For static and editable math fields, when `tabbable` is false, the math field is not part of the page's tab order.
Despite that, the math field can still be focused when selected by a mouse.

Static math fields default to `tabbable: false`, Editable math fields default to `tabbable: true`.

### blurWithCursor

This is a method with the signature `(e: FocusEvent, mq?: AbstractMathQuill) => boolean`. If provided, this method will
be called anytime an editable math field loses focus (for example if the "Tab" key is pressed or the window loses
focus). If the method returns true, then the field will be blurred with the cursor left visible. This means that if
there is a selection in the field, it will not be cleared but will be given an inactive gray styling, and if there is
not a selection then the cursor will remain in the field but will stop blinking. This gives the appearance of no longer
being active but gives indicators as to where the cursor is. This is useful for implementing a toolbar.

## Handlers

Handlers are called after a specified event.
Expand Down Expand Up @@ -159,7 +200,13 @@ Called whenever Enter is pressed.
This is called when the contents of the field might have been changed. This will be called with any edit, such as
something being typed, deleted, or written with the API. Note that this may be called when nothing has actually changed.

Deprecated aliases: `edited`, `reflow`.
### textBlockEnter(mathField)

This is called whenever a text block is started.

### textBlockExit(mathField)

This is called whenver a text block is ended.

## Changing Colors

Expand Down
10 changes: 6 additions & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintConfigPrettier from 'eslint-config-prettier';
import stylistic from '@stylistic/eslint-plugin';
import mochaPlugin from 'eslint-plugin-mocha';

export default [
{
ignores: ['**/dist/**', '.babelrc', 'package.json', 'package-lock.json']
},
{ files: ['**/*.{js,mjs,cjs,ts,tsx}'] },
pluginJs.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
Expand All @@ -30,6 +31,7 @@ export default [
languageOptions: { parserOptions: { project: false, program: null, projectService: false } },
rules: { ...tseslint.configs.disableTypeChecked.rules, '@typescript-eslint/no-require-imports': 'off' }
},
{ files: ['**/test/*.test.js'], ...mochaPlugin.configs.flat.recommended },
eslintConfigPrettier,
{
plugins: { '@stylistic': stylistic },
Expand All @@ -55,13 +57,13 @@ export default [
'no-void': 'off',
'one-var': 'off',

'prefer-promise-reject-errors': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_ignore_' }],
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': ['error', { ignoreRestArgs: true }],
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/only-throw-error': 'off',

'mocha/no-setup-in-describe': 'off',

// Allow console and debugger during development only.
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
Expand Down
Loading