Skip to content

Commit d6eaf52

Browse files
committed
Make sure output renderer settings are transfered when the menu selects a new renderer.
1 parent 0b872a1 commit d6eaf52

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

ts/ui/menu/Menu.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,12 +1087,7 @@ export class Menu {
10871087
this.settings.renderer.replace(/[^a-zA-Z0-9]/g, '') || 'CHTML';
10881088
(Menu._loadingPromise || Promise.resolve()).then(() => {
10891089
const settings = this.settings;
1090-
const options = this.document.outputJax.options;
1091-
options.scale = parseFloat(settings.scale);
1092-
options.displayOverflow = settings.overflow.toLowerCase();
1093-
if (options.linebreaks) {
1094-
options.linebreaks.inline = settings.breakInline;
1095-
}
1090+
this.applyRendererOptions(this.document.outputJax);
10961091
if (!settings.speechRules) {
10971092
const sre = this.document.options.sre;
10981093
settings.speechRules = `${sre.domain || 'clearspeak'}-${sre.style || 'default'}`;
@@ -1143,6 +1138,7 @@ export class Menu {
11431138
*/
11441139
protected setRenderer(jax: string, rerender: boolean = true): Promise<void> {
11451140
if (Object.hasOwn(this.jax, jax) && this.jax[jax]) {
1141+
this.applyRendererOptions(this.jax[jax]);
11461142
return this.setOutputJax(jax, rerender);
11471143
}
11481144
const name = jax.toLowerCase();
@@ -1153,7 +1149,7 @@ export class Menu {
11531149
return fail(new Error(`Component ${name} not loaded`));
11541150
}
11551151
startup.useOutput(name, true);
1156-
startup.output = startup.getOutputJax();
1152+
startup.output = this.applyRendererOptions(startup.getOutputJax());
11571153
startup.output.setAdaptor(this.document.adaptor);
11581154
startup.output.initialize();
11591155
this.jax[jax] = startup.output;
@@ -1164,6 +1160,23 @@ export class Menu {
11641160
});
11651161
}
11661162

1163+
/**
1164+
* @param {OutputJax<HTMLElement, Text, Document>} output The output jax to adjust.
1165+
* @returns {OutputJax<HTMLElement, Text, Document>} The adjusted output jax.
1166+
*/
1167+
protected applyRendererOptions(
1168+
output: OutputJax<HTMLElement, Text, Document>
1169+
): OutputJax<HTMLElement, Text, Document> {
1170+
const settings = this.settings;
1171+
const options = output.options;
1172+
options.scale = parseFloat(settings.scale);
1173+
options.displayOverflow = settings.overflow.toLowerCase();
1174+
if (options.linebreaks) {
1175+
options.linebreaks.inline = settings.breakInline;
1176+
}
1177+
return output;
1178+
}
1179+
11671180
/**
11681181
* Set up the new jax and link it to the document,
11691182
* load any needed extensions, and then rerender the math, if needed

0 commit comments

Comments
 (0)