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

Fix/explorer rules #1079

Merged
merged 6 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
1 change: 0 additions & 1 deletion ts/a11y/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ export function setA11yOption(document: HTMLDOCUMENT, option: string, value: str
break;
case 'locale':
document.options.sre.locale = value;
document.options.a11y.locale = value;
break;
default:
document.options.a11y[option] = value;
Expand Down
2 changes: 1 addition & 1 deletion ts/a11y/semantic-enrich.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export function EnrichedMathDocumentMixin<N, T, D, B extends MathDocumentConstru
sre: expandable({
speech: 'none', // by default no speech is included
locale: 'en', // switch the locale
domain: 'mathspeak', // speech rules domain
domain: 'clearspeak', // speech rules domain
style: 'default', // speech rules style
braille: 'nemeth', // TODO: Dummy switch for braille
}),
Expand Down
2 changes: 1 addition & 1 deletion ts/ui/menu/MJContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class MJContextMenu extends ContextMenu {
*/
public unpost() {
super.unpost();
this.mathItem.typesetRoot.blur();
this.mathItem?.typesetRoot?.blur();
this.mathItem = null;
}

Expand Down
23 changes: 16 additions & 7 deletions ts/ui/menu/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class Menu {
speech: true,
braille: true,
brailleCode: 'nemeth',
speechRules: 'mathspeek-default'
speechRules: 'clearspeak-default'
},
jax: {
CHTML: null,
Expand Down Expand Up @@ -507,11 +507,20 @@ export class Menu {
this.a11yVar<boolean>('viewBraille'),
this.a11yVar<boolean>('voicing'),
this.a11yVar<string>('locale', locale => this.setLocale(locale)),
this.a11yVar<string>('speechRules', value => {
const [domain, style] = value.split('-');
this.document.options.sre.domain = domain;
this.document.options.sre.style = style;
}),
{
name: 'speechRules',
getter: () => {
return this.settings['speechRules'];
},
setter: (value: string) => {
const [domain, style] = value.split('-');
this.settings['speechRules'] = value;
this.document.options.sre.domain = domain;
this.document.options.sre.style = style;
this.rerender(STATE.COMPILED);
this.saveUserSettings();
}
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to use this.variable() rather than this.a11yvar() to define this, so you don't have to do the getter and setter by hand (and won't need to include lines 517 and 521, which are part of what this.variable() does. So

          this.variable<string>('speechRules', value => {
            const [domain, style] = value.split('-');
            this.document.options.sre.domain = domain;
            this.document.options.sre.style = style;
            this.rerender(STATE.COMPILED);
          }),

should do it (that is, changing a11yvar to variable and adding the rerender() call to the original lines 510 to 514 should be enough).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that and it not work. And it drove me crazy, so I decided to stick with the pedestrian version.
But I will try again. Maybe I was just too thick the other day.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried this out, and it seemed to work fine for me. Give it another try, and see if you have any problems.

this.a11yVar<string> ('magnification'),
this.a11yVar<string> ('magnify'),
this.a11yVar<boolean>('treeColoring'),
Expand Down Expand Up @@ -840,7 +849,7 @@ export class Menu {
options.linebreaks.inline = settings.breakInline;
if (!settings.speechRules) {
const sre = this.document.options.sre;
settings.speechRules = `${sre.domain || 'mathspeak'}-${sre.style || 'default'}`;
settings.speechRules = `${sre.domain || 'clearspeak'}-${sre.style || 'default'}`;
}
});
}
Expand Down