Update MathJax contextual menus for assistive tools #1068
Merged
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.
This PR implements the new menu structure that we discussed over the last few developer meetings.
While updating the menus, we also normalize how the settings are handled, so that the
enableSpeech
,enableBraille
,enableEnrichment
andenableExplorer
document options control whether those actions are taken, and are controlled automatically by the menu settings. When enrichment is enabled, the accessibility submenus are made active (and theenable...
options are set to true). This allows the explorer to run, and whatever settings are present in theSpeech
,Braille
, andExplorer
menus to take effect. Those submenus control thea11y
settings of the document's options (and themenuOptions.settings
section, which is what initializes thea11y
values when the menu code is loaded, and are what are stored in the menu'slocalStorage
cache).All of this means that, for example, for speech to be added, both the document's
enableSpeech
anda11y.speech
options must be true, and for the subtitles to be shown, thea11y.substitles
option must also be true. Similarly for the Braille settings. This generated the changes toKeyExplorer.ts
for example.The
setA11yOptions()
function inexplorer.ts
is simplified by moving the handling oflocale
to thesetA11yOption()
function where all the other special keys are processed.The
ExplorerPool.ts
file is modified to attach explorers when speech isn't enabled but one of Braille or magnification is (there were not separate explorer keys for these, as the speech explorer handles all three).In
semantic-enrich.ts
, we add code to remove enrichment if the state drops below the enrichment state, and we add an error function to process enrichment errors that can be overriden by the user.The
MJContextMenu
is modified to:Braille Code
item to theShow As
andCopy to Clipboard
submenus (enabled when Braille generation is active).DynamicSubmenus
code to allow enabling of a non-empty menu to be controlled by a menu setting (so that, for example, thelanguage
submenu does not get enabled when speech is not being generated).findID()
method has been rewritten to not usefind()
, which descends into submenus too soon forfindID()
.The
SpeechMenu.ts
file uses the newDynamicSubmenus
parameter to handle the language and clearspeak submenus.The
MenuHandler
adds theenableSpeech
andenableBraille
options, and handles the transfer of the menu settings to the variousenable...
options. Note thatenableExplorer
andenableEnrichment
are initially the same, since enrichment is all that is needed for the explorer at this point.Finally, the
Menu.ts
file has significant changes to implement the new menu structure and loading of the needed components when the settings change. Theexplorer
menu setting has been removed, since there is no longer an explicit menu setting for it (instead, it is controlled by enrichment setting).It may be useful to turn off white-space difference when looking at the changes.
Note that you will need to use the
lab-menu-update
branch in theMathJax-dev
repository to get the needed changes to the lab in order for the lab to work with this branch.