mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-27 15:40:00 +00:00
Add option to disable CodeMirror frontend
So CodeMirror only provides it's libraries to use in other code. Change-Id: I6832f4d82ae0497b92ba210ac7960052e4e12143
This commit is contained in:
parent
c911e6d003
commit
6bd068ca90
|
@ -66,10 +66,13 @@ class CodeMirrorHooks {
|
|||
* @return boolean
|
||||
*/
|
||||
private static function isCodeMirrorEnabled( IContextSource $context ) {
|
||||
global $wgCodeMirrorEnableFrontend;
|
||||
|
||||
// Check, if we already checked, if page action is editing, if not, do it now
|
||||
if ( is_null( self::$isEnabled ) ) {
|
||||
// edit can be 'edit' and 'submit'
|
||||
self::$isEnabled = in_array(
|
||||
self::$isEnabled = $wgCodeMirrorEnableFrontend &&
|
||||
in_array(
|
||||
Action::getActionName( $context ),
|
||||
array( 'edit', 'submit' )
|
||||
);
|
||||
|
@ -176,10 +179,12 @@ class CodeMirrorHooks {
|
|||
* @return bool Always true
|
||||
*/
|
||||
public static function onGetPreferences( User $user, &$defaultPreferences ) {
|
||||
if ( self::isCodeMirrorEnabled( RequestContext::getMain() ) ) {
|
||||
$defaultPreferences['usecodemirror'] = array(
|
||||
'type' => 'api',
|
||||
'default' => '1',
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,3 +71,11 @@ $wgResourceModules['ext.CodeMirror.lib'] = $wgCodeMirrorResourceTemplate + array
|
|||
'group' => 'ext.CodeMirror',
|
||||
'targets' => array( 'mobile', 'desktop' ),
|
||||
);
|
||||
|
||||
// Configuration options
|
||||
|
||||
/**
|
||||
* Specify, if CodeMirror extension should integrate CodeMirror in MediaWiki's editor (or WikiEditor), or if
|
||||
* it should work as a library provider for other extensions.
|
||||
*/
|
||||
$wgCodeMirrorEnableFrontend = true;
|
||||
|
|
Loading…
Reference in a new issue