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,enableEnrichmentandenableExplorerdocument 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, andExplorermenus to take effect. Those submenus control thea11ysettings of the document's options (and themenuOptions.settingssection, which is what initializes thea11yvalues when the menu code is loaded, and are what are stored in the menu'slocalStoragecache).All of this means that, for example, for speech to be added, both the document's
enableSpeechanda11y.speechoptions must be true, and for the subtitles to be shown, thea11y.substitlesoption must also be true. Similarly for the Braille settings. This generated the changes toKeyExplorer.tsfor example.The
setA11yOptions()function inexplorer.tsis simplified by moving the handling oflocaleto thesetA11yOption()function where all the other special keys are processed.The
ExplorerPool.tsfile 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
MJContextMenuis modified to:Braille Codeitem to theShow AsandCopy to Clipboardsubmenus (enabled when Braille generation is active).DynamicSubmenuscode to allow enabling of a non-empty menu to be controlled by a menu setting (so that, for example, thelanguagesubmenu 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.tsfile uses the newDynamicSubmenusparameter to handle the language and clearspeak submenus.The
MenuHandleradds theenableSpeechandenableBrailleoptions, and handles the transfer of the menu settings to the variousenable...options. Note thatenableExplorerandenableEnrichmentare initially the same, since enrichment is all that is needed for the explorer at this point.Finally, the
Menu.tsfile has significant changes to implement the new menu structure and loading of the needed components when the settings change. Theexplorermenu 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-updatebranch in theMathJax-devrepository to get the needed changes to the lab in order for the lab to work with this branch.