Should be possible to disable the Math preview

Bug: T334261
Change-Id: I46e7641d22f4c17ba318a106a62518e4ca3e3c55
This commit is contained in:
Jon Robson 2023-10-17 16:28:57 -07:00 committed by Jdlrobson
parent 7f8a359a84
commit b99c3800d0
6 changed files with 32 additions and 8 deletions

View file

@ -27,7 +27,8 @@
"MediaWiki\\Extension\\Math\\WikiTexVC\\MMLmappings\\Util\\MMLComparator": "tests/phpunit/unit/WikiTexVC/MMLComparator.php"
},
"DefaultUserOptions": {
"math": "mathml"
"math": "mathml",
"math-popups": "1"
},
"ExtensionMessagesFiles": {
"MathAlias": "Math.alias.php",
@ -216,8 +217,12 @@
"ext.math.popup": {
"es6": true,
"packageFiles": "ext.math.popup.js",
"messages": [
"popups-settings-option-math",
"popups-settings-option-math-description"
],
"dependencies": [
"mediawiki.api"
"mediawiki.ForeignApi"
]
},
"mw.widgets.MathWbEntitySelector": {

View file

@ -18,6 +18,9 @@
]
},
"math-desc": "Render mathematical formulas between <code>&lt;math&gt;</code> ... <code>&lt;/math&gt;</code> tags",
"popups-settings-option-math": "Math",
"popups-settings-option-math-description": "Explain mathematical formulae.",
"popups-settings-option-math-tooltip": "Explain mathematical formulae on hover.",
"math-visualeditor-mwchemdialog-title": "Chemical formula",
"math-visualeditor-mwlatexcontextitem-quickedit": "Quick edit",
"math-visualeditor-mwlatexdialog-card-formula": "Formula",

View file

@ -18,6 +18,9 @@
]
},
"math-desc": "{{desc|name=Math|url=https://www.mediawiki.org/wiki/Extension:Math}}",
"popups-settings-option-math": "Page previews setting dialog for math previews.",
"popups-settings-option-math-description": "Describe the functionality of the math preview in a dialog for anonymous users.",
"popups-settings-option-math-tooltip": "Describe the functionality of the math preview on Special:Preferences page.",
"math-visualeditor-mwchemdialog-title": "Title for the dialog to edit <nowiki><chem></nowiki> formula blocks.",
"math-visualeditor-mwlatexcontextitem-quickedit": "Label for the quick edit button in the math context item",
"math-visualeditor-mwlatexdialog-card-formula": "Label for the generic formula card of the dialog for mathematics, chemistry, etc.\n{{Identical|Formula}}",

View file

@ -1,11 +1,12 @@
{
"root": true,
"extends": [
"wikimedia/client-es5",
"wikimedia/client-es6",
"wikimedia/jquery",
"wikimedia/mediawiki"
],
"rules": {
"max-len": "off"
"max-len": "off",
"no-var": "warn"
}
}

View file

@ -42,12 +42,17 @@
}
}
);
module.exports = {
const mathDisabledByUser = mw.user.isNamed() && mw.user.options.get( 'math-popups' ) !== '1';
const selector = '.mwe-math-element[data-qid] img';
const mathAppliesToThisPage = document.querySelectorAll( selector ).length > 0;
module.exports = !mathAppliesToThisPage || mathDisabledByUser ? null : {
type: previewType,
selector: '.mwe-math-element[data-qid] img',
selector,
gateway: {
fetch: fetch,
fetchPreviewForTitle: fetchPreviewForTitle
fetch,
fetchPreviewForTitle
}
};
}() );

View file

@ -45,5 +45,12 @@ class PreferencesHooksHandler implements
'label' => '&#160;',
'section' => 'rendering/math',
];
$preferences['math-popups'] = [
'type' => 'toggle',
'label-message' => 'popups-settings-option-math-tooltip',
'section' => 'rendering/math',
'help-message' => 'popups-settings-option-math-tooltip-description'
];
}
}