@@ -240,12 +240,15 @@ export function ExplorerMathDocumentMixin<B extends MathDocumentConstructor<HTML
240240 */
241241 public static OPTIONS : OptionList = {
242242 ...BaseDocument . OPTIONS ,
243- enrichSpeech : 'shallow' , // overrides option in EnrichedMathDocument
244243 enableExplorer : true ,
245244 renderActions : expandable ( {
246245 ...BaseDocument . OPTIONS . renderActions ,
247246 explorable : [ STATE . EXPLORER ]
248247 } ) ,
248+ sre : expandable ( {
249+ ...BaseDocument . OPTIONS . sre ,
250+ speech : 'shallow' , // overrides option in EnrichedMathDocument
251+ } ) ,
249252 a11y : {
250253 align : 'top' , // placement of magnified expression
251254 backgroundColor : 'Blue' , // color for background of selected sub-expression
@@ -260,12 +263,10 @@ export function ExplorerMathDocumentMixin<B extends MathDocumentConstructor<HTML
260263 infoRole : false , // show semantic role on mouse hovering
261264 infoType : false , // show semantic type on mouse hovering
262265 keyMagnifier : false , // switch on magnification via key exploration
263- locale : 'en' , // switch the locale
264266 magnification : 'None' , // type of magnification
265267 magnify : '400%' , // percentage of magnification of zoomed expressions
266268 mouseMagnifier : false , // switch on magnification via mouse hovering
267269 speech : true , // switch on speech output
268- speechRules : 'mathspeak-default' , // speech rules as domain-style pair
269270 subtitles : true , // show speech as a subtitle
270271 treeColoring : false , // tree color expression
271272 viewBraille : false // display Braille output as subtitles
@@ -285,6 +286,7 @@ export function ExplorerMathDocumentMixin<B extends MathDocumentConstructor<HTML
285286 * @constructor
286287 */
287288 constructor ( ...args : any [ ] ) {
289+ processSreOptions ( args [ 2 ] ) ;
288290 super ( ...args ) ;
289291 const ProcessBits = ( this . constructor as typeof BaseDocument ) . ProcessBits ;
290292 if ( ! ProcessBits . has ( 'explorer' ) ) {
@@ -293,6 +295,7 @@ export function ExplorerMathDocumentMixin<B extends MathDocumentConstructor<HTML
293295 const visitor = new SerializedMmlVisitor ( this . mmlFactory ) ;
294296 const toMathML = ( ( node : MmlNode ) => visitor . visitTree ( node ) ) ;
295297 this . options . MathItem = ExplorerMathItemMixin ( this . options . MathItem , toMathML ) ;
298+ // TODO: set backward compatibility options here.
296299 this . explorerRegions = initExplorerRegions ( this ) ;
297300 }
298301
@@ -328,6 +331,33 @@ export function ExplorerMathDocumentMixin<B extends MathDocumentConstructor<HTML
328331
329332}
330333
334+ //
335+ // TODO(v3.2): This is for backward compatibility of old option parameters.
336+ //
337+ /**
338+ * Processes old a11y options for backward compatibility.
339+ * @param {OptionList } options The options to process.
340+ */
341+ function processSreOptions ( options : OptionList ) {
342+ if ( ! options || ! options . a11y ) {
343+ return ;
344+ }
345+ if ( ! options . sre ) {
346+ options . sre = { } ;
347+ }
348+ if ( options . a11y . locale ) {
349+ options . sre . locale = options . a11y . locale ;
350+ delete options . a11y . locale ;
351+ }
352+ if ( options . a11y . speechRules ) {
353+ let [ domain , style ] = ( options . a11y . speechRules as string ) . split ( '-' ) ;
354+ options . sre . domain = domain ;
355+ options . sre . style = style ;
356+ delete options . a11y . speechRules ;
357+ }
358+ }
359+
360+
331361/*==========================================================================*/
332362
333363/**
@@ -392,10 +422,9 @@ let allExplorers: {[options: string]: ExplorerInit} = {
392422 speech : ( doc : ExplorerMathDocument , node : HTMLElement , ...rest : any [ ] ) => {
393423 let explorer = ke . SpeechExplorer . create (
394424 doc , doc . explorerRegions . speechRegion , node , ...rest ) as ke . SpeechExplorer ;
395- let [ domain , style ] = doc . options . a11y . speechRules . split ( '-' ) ;
396425 explorer . speechGenerator . setOptions ( {
397- locale : doc . options . a11y . locale , domain : domain ,
398- style : style , modality : 'speech' , cache : false } ) ;
426+ locale : doc . options . sre . locale , domain : doc . options . sre . domain ,
427+ style : doc . options . sre . style , modality : 'speech' , cache : false } ) ;
399428 explorer . showRegion = 'subtitles' ;
400429 return explorer ;
401430 } ,
@@ -458,9 +487,17 @@ function initExplorers(document: ExplorerMathDocument, node: HTMLElement, mml: s
458487 * @param {{[key: string]: any} } options Association list for a11y option value pairs.
459488 */
460489export function setA11yOptions ( document : HTMLDOCUMENT , options : { [ key : string ] : any } ) {
490+ let sreOptions = SRE . engineSetup ( ) as { [ name : string ] : string } ;
461491 for ( let key in options ) {
462492 if ( document . options . a11y [ key ] !== undefined ) {
463493 setA11yOption ( document , key , options [ key ] ) ;
494+ if ( key === 'locale' ) {
495+ document . options . sre [ key ] = options [ key ] ;
496+ }
497+ continue ;
498+ }
499+ if ( sreOptions [ key ] !== undefined ) {
500+ document . options . sre [ key ] = options [ key ] ;
464501 }
465502 }
466503 // Reinit explorers
@@ -516,6 +553,19 @@ export function setA11yOption(document: HTMLDOCUMENT, option: string, value: str
516553 break ;
517554 }
518555 break ;
556+ //
557+ // TODO(v3.2): These two cases should be handled directly in the menu
558+ // variable actions.
559+ //
560+ case 'speechRules' :
561+ let [ domain , style ] = ( value as string ) . split ( '-' ) ;
562+ document . options . sre . domain = domain ;
563+ document . options . sre . style = style ;
564+ break ;
565+ case 'locale' :
566+ document . options . sre . locale = value ;
567+ SRE . setupEngine ( { locale : value as string } ) ;
568+ break ;
519569 default :
520570 document . options . a11y [ option ] = value ;
521571 }
0 commit comments