refactor: Remove some hard-coding in the MathJax subtype.

This commit is contained in:
Daniel J. Geiger 2023-11-22 15:50:07 -06:00
parent 9642a6e756
commit 5164bdb782

View File

@ -26,7 +26,7 @@ import Scene from "../../../scene/Scene";
// Imports for actions // Imports for actions
import { t, registerAuxLangData } from "../../../i18n"; import { t, registerAuxLangData } from "../../../i18n";
import { Action } from "../../../actions/types"; import { Action, makeCustomActionName } from "../../../actions/types";
import { AppState } from "../../../types"; import { AppState } from "../../../types";
import { import {
changeProperty, changeProperty,
@ -1395,7 +1395,7 @@ const enableActionChangeMathProps = (
const createMathActions = () => { const createMathActions = () => {
const mathActions: Action[] = []; const mathActions: Action[] = [];
const actionUseTexTrue: Action = { const actionUseTexTrue: Action = {
name: "custom.useTexTrue", name: makeCustomActionName("useTexTrue"),
perform: (elements, appState) => { perform: (elements, appState) => {
const mathOnly = getMathProps.getMathOnly(appState); const mathOnly = getMathProps.getMathOnly(appState);
const customData = appState.customData ?? {}; const customData = appState.customData ?? {};
@ -1414,7 +1414,7 @@ const createMathActions = () => {
trackEvent: false, trackEvent: false,
}; };
const actionUseTexFalse: Action = { const actionUseTexFalse: Action = {
name: "custom.useTexFalse", name: makeCustomActionName("useTexFalse"),
perform: (elements, appState) => { perform: (elements, appState) => {
const mathOnly = getMathProps.getMathOnly(appState); const mathOnly = getMathProps.getMathOnly(appState);
const customData = appState.customData ?? {}; const customData = appState.customData ?? {};
@ -1433,7 +1433,7 @@ const createMathActions = () => {
trackEvent: false, trackEvent: false,
}; };
const actionResetUseTex: Action = { const actionResetUseTex: Action = {
name: "custom.resetUseTex", name: makeCustomActionName("resetUseTex"),
perform: (elements, appState) => { perform: (elements, appState) => {
const useTex = getMathProps.getUseTex(appState); const useTex = getMathProps.getUseTex(appState);
const modElements = changeProperty( const modElements = changeProperty(
@ -1481,7 +1481,7 @@ const createMathActions = () => {
trackEvent: false, trackEvent: false,
}; };
const actionChangeMathOnly: Action = { const actionChangeMathOnly: Action = {
name: "custom.changeMathOnly", name: makeCustomActionName("changeMathOnly"),
perform: (elements, appState, mathOnly: boolean | null) => { perform: (elements, appState, mathOnly: boolean | null) => {
if (mathOnly === null) { if (mathOnly === null) {
mathOnly = getFormValue( mathOnly = getFormValue(