mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-27 15:40:00 +00:00
Move check for 'usebetatoolbar' from JS to PHP
This change avoids useless loading of the module 'ext.CodeMirror'. Change-Id: I2637487b72c028d272748f2891239401412f77b5
This commit is contained in:
parent
652c4585bd
commit
b17c8b7557
|
@ -14,6 +14,10 @@ class CodeMirrorHooks {
|
||||||
if ( in_array( 'ext.codeEditor', $out->getModules() ) ) {
|
if ( in_array( 'ext.codeEditor', $out->getModules() ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Disable CodeMirror when the WikiEditor toolbar is not enabled in preferences
|
||||||
|
if ( !$out->getUser()->getOption( 'usebetatoolbar' ) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$context = $out->getContext();
|
$context = $out->getContext();
|
||||||
return in_array( Action::getActionName( $context ), [ 'edit', 'submit' ] ) &&
|
return in_array( Action::getActionName( $context ), [ 'edit', 'submit' ] ) &&
|
||||||
// CodeMirror on textarea wikitext editors doesn't support RTL (T170001)
|
// CodeMirror on textarea wikitext editors doesn't support RTL (T170001)
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
// Exit if WikiEditor is disabled
|
// Exit if WikiEditor is disabled
|
||||||
// usebetatoolbar can be the string "0" if the user disabled the preference - Bug T54542#555387
|
if ( !mw.loader.getState( 'ext.wikiEditor' ) ) {
|
||||||
if ( !( mw.loader.getState( 'ext.wikiEditor' ) && mw.user.options.get( 'usebetatoolbar' ) > 0 ) ) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue