Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions components/mjs/a11y/a11y.js

This file was deleted.

19 changes: 0 additions & 19 deletions components/mjs/a11y/config.json

This file was deleted.

5 changes: 0 additions & 5 deletions components/mjs/a11y/en.js

This file was deleted.

20 changes: 14 additions & 6 deletions components/mjs/a11y/explorer/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
"component": "a11y/explorer",
"targets": ["a11y/explorer.ts", "a11y/explorer"]
},
"copy": {
"to": "[bundle]/a11y/explorer",
"from": "[ts]/a11y/explorer",
"copy": ["__locales__"],
"excludes": ["__locales__/Component.ts"]
},
"copy": [
{
"to": "[bundle]/a11y/explorer",
"from": "[ts]/a11y/explorer",
"copy": ["__locales__"],
"excludes": ["__locales__/Component.ts"]
},
{
"to": "[bundle]/a11y/aria",
"from": "[ts]/a11y/aria",
"copy": ["__locales__"],
"excludes": ["__locales__/Component.ts"]
}
],
"webpack": {
"name": "a11y/explorer",
"libs": [
Expand Down
20 changes: 14 additions & 6 deletions components/mjs/ui/menu/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@
"targets": ["ui/menu", "a11y/speech/SpeechMenu.ts"],
"excludeSubdirs": true
},
"copy": {
"to": "[bundle]/ui/menu",
"from": "[ts]/ui/menu",
"copy": ["__locales__"],
"excludes": ["__locales__/Component.ts"]
},
"copy": [
{
"to": "[bundle]/ui/menu",
"from": "[ts]/ui/menu",
"copy": ["__locales__"],
"excludes": ["__locales__/Component.ts"]
},
{
"to": "[bundle]/a11y/aria",
"from": "[ts]/a11y/aria",
"copy": ["__locales__"],
"excludes": ["__locales__/Component.ts"]
}
],
"webpack": {
"name": "ui/menu",
"libs": [
Expand Down
60 changes: 0 additions & 60 deletions ts/a11y/aria.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@
*/

/**
* @file Locale component registration for a11y/explorer
* @file Locale component registration for a11y/aria
*
* @author dpvc@mathjax.org (Davide P. Cervone)
*/

import { Locale, namedData } from '../../util/Locale.js';
import { Locale, namedData } from '../../../util/Locale.js';
import data from '#ts/a11y/aria/__locales__/en.json' with {type: 'json'};

export const COMPONENT = 'a11y';
export const COMPONENT = 'a11y/aria';

Locale.registerLocaleFiles(COMPONENT, '../ts/a11y');
Locale.registerLocaleFiles(COMPONENT, '../../ts/a11y/aira');
Locale.registerMessages(COMPONENT, 'en', data);

/**
* Prefix to use for roleDescription localization
*/
export const roleDescPrefix = 'Aria/RoleDescription';

/**
* Get a localized message for this component
Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions ts/a11y/explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import { StyleJson } from '../util/StyleJson.js';
import { context } from '../util/context.js';

import { ExplorerPool, RegionPool } from './explorer/ExplorerPool.js';
import { AriaRoleDescription, localizeAria } from './aria.js';

import * as Sre from './sre.js';
import * as Aria from './aria/__locales__/Component.js';

const isUnix = context.os === 'Unix';

Expand Down Expand Up @@ -136,7 +136,7 @@ export function ExplorerMathItemMixin<B extends Constructor<HTMLMATHITEM>>(
/**
* The aria-roleDescription to use for the math
*/
protected static roleDescription: string = AriaRoleDescription.MATH;
protected static roleDescription: string = 'math';

/**
* Decription to use when set to none
Expand All @@ -155,9 +155,9 @@ export function ExplorerMathItemMixin<B extends Constructor<HTMLMATHITEM>>(

public get roleDescription() {
const CLASS = this.constructor as typeof BaseClass;
return CLASS.roleDescription === AriaRoleDescription.NONE
return CLASS.roleDescription === 'none'
? CLASS.none
: (localizeAria(CLASS.roleDescription) ?? CLASS.roleDescription);
: Aria.localize(`${Aria.roleDescPrefix}/${CLASS.roleDescription}`);
}

public get none() {
Expand Down
2 changes: 1 addition & 1 deletion ts/a11y/explorer/KeyExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ export class SpeechExplorer
const description = item.roleDescription;
const speech =
(container.getAttribute(SemAttr.SPEECH) || '') +
(description ? ', ' + description : '');
(description && description !== this.none ? ', ' + description : '');
this.img?.remove();
this.img = this.document.adaptor.node('mjx-speech', {
'aria-label': speech,
Expand Down
58 changes: 45 additions & 13 deletions ts/ui/menu/MJContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,27 @@ export type DynamicSubmenu = (
callback: SubmenuCallback
) => void;

/**
* Remap old menu ids to their new localization keys
*/
const RemapIds: {[key: string]: any} = {
Settings: {
Overflow: 'Wide/Expressions',
},
Speech: {
'Auto Voicing': 'AutoVoicing',
},
Braille: {
BrailleSpeech: 'Braille/Speech',
BrailleCombine: 'Braille/Combine',
},
Explorer: {
'Semantic Info': 'SemanticInfo',
'Role Description': 'RoleDescription',
'Math Help': 'MathHelp',
}
};

/*==========================================================================*/

/**
Expand Down Expand Up @@ -132,15 +153,26 @@ export class MJContextMenu extends ContextMenu {
* Find an item in the menu (recursively descending into submenus, if needed)
*
* @param {string[]} names The menu IDs to look for
* @returns {Item} The menu item (or null if not found)
* @returns {Item} The menu item (or null if not found)
*/
public findID(...names: string[]): Item {
let map = RemapIds;
let menu = this as Menu;
let item = null as Item;
for (const name of names) {
for (const fullname of names) {
if (!menu) return null;
//
// Remap old menu ids to new prefixed ones
// (can be removed in a later version)
//
const remap = map?.[fullname];
const name = typeof remap === 'string' ? remap : fullname;
map = typeof remap === 'object' ? remap : null;
//
// Look for the id in the menu list
//
for (item of menu.items) {
if (item.id === name) {
if (item.id === name || item.id?.replace(/.*\//, '') === name) {
menu = item instanceof Submenu ? item.submenu : null;
break;
}
Expand All @@ -166,12 +198,12 @@ export class MJContextMenu extends ContextMenu {
*/
protected getOriginalMenu() {
const input = this.mathItem.inputJax.name;
const original = this.findID('Show', 'Show/Original');
const original = this.findID('Show', 'Original');
original.content =
input === 'MathML'
? localize('Show/OriginalMathML')
: localize('Show/Commands', input);
const clipboard = this.findID('Copy', 'Show/Original');
const clipboard = this.findID('Copy', 'Original');
clipboard.content = original.content;
}

Expand All @@ -190,26 +222,26 @@ export class MJContextMenu extends ContextMenu {
*/
protected getSpeechMenu() {
const speech = this.mathItem.outputData.speech;
this.findID('Show', 'Show/SpeechText')[speech ? 'enable' : 'disable']();
this.findID('Copy', 'Show/SpeechText')[speech ? 'enable' : 'disable']();
this.findID('Show', 'Speech')[speech ? 'enable' : 'disable']();
this.findID('Copy', 'Speech')[speech ? 'enable' : 'disable']();
}

/**
* Enable/disable the Braille menus
*/
protected getBrailleMenu() {
const braille = this.mathItem.outputData.braille;
this.findID('Show', 'Show/BrailleCode')[braille ? 'enable' : 'disable']();
this.findID('Copy', 'Show/BrailleCode')[braille ? 'enable' : 'disable']();
this.findID('Show', 'Braille')[braille ? 'enable' : 'disable']();
this.findID('Copy', 'Braille')[braille ? 'enable' : 'disable']();
}

/**
* Enable/disable the svg menus
*/
protected getSvgMenu() {
const svg = this.jax.SVG;
this.findID('Show', 'Show/SvgImage')[svg ? 'enable' : 'disable']();
this.findID('Copy', 'Show/SvgImage')[svg ? 'enable' : 'disable']();
this.findID('Show', 'SVG')[svg ? 'enable' : 'disable']();
this.findID('Copy', 'SVG')[svg ? 'enable' : 'disable']();
}

/**
Expand All @@ -226,8 +258,8 @@ export class MJContextMenu extends ContextMenu {
'') as string;
disable = !this.errorMsg;
}
this.findID('Show', 'Show/Error')[disable ? 'disable' : 'enable']();
this.findID('Copy', 'Show/Error')[disable ? 'disable' : 'enable']();
this.findID('Show', 'Error')[disable ? 'disable' : 'enable']();
this.findID('Copy', 'Error')[disable ? 'disable' : 'enable']();
}

/*======================================================================*/
Expand Down
Loading