Skip to content

Commit 0a66984

Browse files
authored
Merge pull request #1079 from mathjax/fix/explorer_rules
Fix/explorer rules
2 parents da33c5d + 10a5ec8 commit 0a66984

File tree

4 files changed

+33
-16
lines changed

4 files changed

+33
-16
lines changed

ts/a11y/explorer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ export function setA11yOption(document: HTMLDOCUMENT, option: string, value: str
383383
break;
384384
case 'locale':
385385
document.options.sre.locale = value;
386-
document.options.a11y.locale = value;
387386
break;
388387
default:
389388
document.options.a11y[option] = value;

ts/a11y/semantic-enrich.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ export function EnrichedMathDocumentMixin<N, T, D, B extends MathDocumentConstru
382382
sre: expandable({
383383
speech: 'none', // by default no speech is included
384384
locale: 'en', // switch the locale
385-
domain: 'mathspeak', // speech rules domain
385+
domain: 'clearspeak', // speech rules domain
386386
style: 'default', // speech rules style
387387
braille: 'nemeth', // TODO: Dummy switch for braille
388388
}),

ts/ui/menu/MJContextMenu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class MJContextMenu extends ContextMenu {
9191
*/
9292
public unpost() {
9393
super.unpost();
94-
this.mathItem.typesetRoot.blur();
94+
this.mathItem?.typesetRoot?.blur();
9595
this.mathItem = null;
9696
}
9797

ts/ui/menu/Menu.ts

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class Menu {
146146
speech: true,
147147
braille: true,
148148
brailleCode: 'nemeth',
149-
speechRules: 'mathspeek-default'
149+
speechRules: 'clearspeak-default'
150150
},
151151
jax: {
152152
CHTML: null,
@@ -498,7 +498,7 @@ export class Menu {
498498
this.a11yVar<boolean>('speech', speech => this.setSpeech(speech)),
499499
this.a11yVar<boolean>('braille', braille => this.setBraille(braille)),
500500
this.variable<string>('brailleCode', code => this.setBrailleCode(code)),
501-
this.a11yVar<string> ('highlight'),
501+
this.a11yVar<string> ('highlight', value => this.setHighlight(value)),
502502
this.a11yVar<string> ('backgroundColor'),
503503
this.a11yVar<string> ('backgroundOpacity'),
504504
this.a11yVar<string> ('foregroundColor'),
@@ -507,10 +507,11 @@ export class Menu {
507507
this.a11yVar<boolean>('viewBraille'),
508508
this.a11yVar<boolean>('voicing'),
509509
this.a11yVar<string>('locale', locale => this.setLocale(locale)),
510-
this.a11yVar<string>('speechRules', value => {
510+
this.variable<string>('speechRules', value => {
511511
const [domain, style] = value.split('-');
512512
this.document.options.sre.domain = domain;
513513
this.document.options.sre.style = style;
514+
this.rerender(STATE.COMPILED);
514515
}),
515516
this.a11yVar<string> ('magnification'),
516517
this.a11yVar<string> ('magnify'),
@@ -675,9 +676,6 @@ export class Menu {
675676
menu.setJax(this.jax);
676677
this.attachDialogMenus(menu);
677678
this.checkLoadableItems();
678-
this.enableAccessibilityItems('Speech', this.settings.speech);
679-
this.enableAccessibilityItems('Braille', this.settings.braille);
680-
this.setAccessibilityMenus();
681679
const cache: [string, string][] = [];
682680
MJContextMenu.DynamicSubmenus.set(
683681
'ShowAnnotation',
@@ -823,9 +821,9 @@ export class Menu {
823821
this.setTabOrder(this.settings.inTabOrder);
824822
const options = this.document.options;
825823
options.enableAssistiveMml = this.settings.assistiveMml;
826-
options.enableSpeech = this.settings.speech;
827-
options.enableBraille = this.settings.braille;
828-
options.enableExplorer = this.settings.enrich;
824+
this.enableAccessibilityItems('Speech', this.settings.speech);
825+
this.enableAccessibilityItems('Braille', this.settings.braille);
826+
this.setAccessibilityMenus();
829827
const renderer = this.settings.renderer.replace(/[^a-zA-Z0-9]/g, '') || 'CHTML';
830828
const promise = (Menu._loadingPromise || Promise.resolve()).then(
831829
() => (renderer !== this.defaultSettings.renderer ?
@@ -840,7 +838,7 @@ export class Menu {
840838
options.linebreaks.inline = settings.breakInline;
841839
if (!settings.speechRules) {
842840
const sre = this.document.options.sre;
843-
settings.speechRules = `${sre.domain || 'mathspeak'}-${sre.style || 'default'}`;
841+
settings.speechRules = `${sre.domain || 'clearspeak'}-${sre.style || 'default'}`;
844842
}
845843
});
846844
}
@@ -940,6 +938,8 @@ export class Menu {
940938
const enable = this.settings.enrich;
941939
const method = (enable ? 'enable' : 'disable');
942940
['Speech', 'Braille', 'Explorer'].forEach(id => this.menu.findID(id)[method]());
941+
const options = this.document.options;
942+
options.enableSpeech = options.enableBraille = options.enableExplorer = enable;
943943
if (!enable) {
944944
this.settings.collapsible = false;
945945
this.document.options.enableCollapsible = false;
@@ -992,7 +992,7 @@ export class Menu {
992992
* @param {boolean} enrich True to enable enriched math, false to not
993993
*/
994994
protected setEnrichment(enrich: boolean) {
995-
this.document.options.enableEnrichment = this.document.options.enableExplorer = enrich;
995+
this.document.options.enableEnrichment = enrich;
996996
this.setAccessibilityMenus();
997997
if (!enrich || MathJax._?.a11y?.['semantic-enrich']) {
998998
this.rerender(STATE.COMPILED);
@@ -1007,8 +1007,11 @@ export class Menu {
10071007
protected setCollapsible(collapse: boolean) {
10081008
this.document.options.enableComplexity = collapse;
10091009
if (collapse && !this.settings.enrich) {
1010-
this.settings.enrich = true;
1011-
this.setEnrichment(true);
1010+
this.settings.enrich = this.document.options.enableEnrichment = true;
1011+
this.setAccessibilityMenus();
1012+
}
1013+
if (!collapse) {
1014+
this.menu.pool.lookup('highlight').setValue('None');
10121015
}
10131016
if (!collapse || MathJax._?.a11y?.complexity) {
10141017
this.rerender(STATE.COMPILED);
@@ -1020,6 +1023,21 @@ export class Menu {
10201023
}
10211024
}
10221025

1026+
/**
1027+
* @param {string} value The value that highlighting should have
1028+
*/
1029+
protected setHighlight(value: string) {
1030+
if (value === 'None') return;
1031+
if (!this.settings.collapsible) {
1032+
//
1033+
// Turn on collapsible math if it isn't already
1034+
//
1035+
const variable = this.menu.pool.lookup('collapsible');
1036+
variable.setValue(true);
1037+
(variable as any).items[0]?.executeCallbacks_?.();
1038+
}
1039+
}
1040+
10231041
/**
10241042
* Request the scaling value from the user and save it in the settings
10251043
*/

0 commit comments

Comments
 (0)